Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export class OpenTelemetryConstants {
public static readonly GEN_AI_EXECUTION_SOURCE_ID_KEY = 'gen_ai.execution.sourceMetadata.id';
public static readonly GEN_AI_EXECUTION_SOURCE_NAME_KEY = 'gen_ai.channel.name';
public static readonly GEN_AI_EXECUTION_SOURCE_DESCRIPTION_KEY = 'gen_ai.channel.link';
public static readonly GEN_AI_EXECUTION_SOURCE_SUBCHANNEL_KEY = 'gen_ai.channel.subchannel';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this property does not exist on the sentinel service.
We cannot introduce new properties without agreement with the service.


// Custom parent id and parent name key
public static readonly CUSTOM_PARENT_SPAN_ID_KEY = 'custom.parent.span.id';
Expand Down
3 changes: 3 additions & 0 deletions packages/agents-a365-observability/src/tracing/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export interface SourceMetadata {

/** Optional description providing additional context about the source */
description?: string;

/** Optional subchannel identifier */
subchannel?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not required. Lets capture sub channel in channel links field

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,16 @@ export class BaggageBuilder {
return this;
}

/**
* Set the execution source metadata subchannel.
* @param value The source metadata subchannel
* @returns Self for method chaining
*/
sourceMetadataSubchannel(value: string | null | undefined): BaggageBuilder {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not required

this.set(OpenTelemetryConstants.GEN_AI_EXECUTION_SOURCE_SUBCHANNEL_KEY, value);
return this;
}

/**
* Set multiple baggage pairs from a dictionary or iterable.
* @param pairs Dictionary or iterable of key-value pairs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ export const INVOKE_AGENT_ATTRIBUTES: readonly string[] = [
consts.GEN_AI_EXECUTION_SOURCE_ID_KEY,
consts.GEN_AI_EXECUTION_SOURCE_NAME_KEY,
consts.GEN_AI_EXECUTION_SOURCE_DESCRIPTION_KEY,
consts.GEN_AI_EXECUTION_SOURCE_SUBCHANNEL_KEY,
];
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export class InvokeAgentScope extends OpenTelemetryScope {
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_EXECUTION_SOURCE_ID_KEY, requestToUse.sourceMetadata.id);
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_EXECUTION_SOURCE_NAME_KEY, requestToUse.sourceMetadata.name);
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_EXECUTION_SOURCE_DESCRIPTION_KEY, requestToUse.sourceMetadata.description);
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_EXECUTION_SOURCE_SUBCHANNEL_KEY, requestToUse.sourceMetadata.subchannel);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,4 @@ export abstract class OpenTelemetryScope implements Disposable {
public dispose(): void {
this[Symbol.dispose]();
}

}
10 changes: 10 additions & 0 deletions tests/observability/core/BaggageBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,16 @@ describe('BaggageBuilder', () => {
});
});

describe('metadata support', () => {
it('should set source metadata subchannel', () => {
const scope = new BaggageBuilder()
.sourceMetadataSubchannel('sub-A')
.build();
const bag = propagation.getBaggage((scope as any).contextWithBaggage);
expect(bag?.getEntry(OpenTelemetryConstants.GEN_AI_EXECUTION_SOURCE_SUBCHANNEL_KEY)?.value).toBe('sub-A');
});
});

});

describe('BaggageScope', () => {
Expand Down
19 changes: 19 additions & 0 deletions tests/observability/core/scopes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,25 @@ describe('Scopes', () => {
expect(() => scope?.recordError(error)).not.toThrow();
scope?.dispose();
});

it('should accept sourceMetadata attributes without error', () => {
const invokeAgentDetails: InvokeAgentDetails = {
agentId: 'test-agent',
request: {
content: 'hello',
sourceMetadata: {
id: 'chan-123',
name: 'RootChannel',
description: 'Primary channel',
subchannel: 'thread-7'
}
}
};
expect(() => {
const scope = InvokeAgentScope.start(invokeAgentDetails, testTenantDetails);
scope?.dispose();
}).not.toThrow();
});
});

describe('ExecuteToolScope', () => {
Expand Down