Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sdk-trace-base): add dropped attributes and events count on span #3576

Merged
merged 36 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b2c9f40
feat(sdk-trace-base): add dropped attributes and events count on span
mohitk05 Jan 27, 2023
55a26b8
feat(sdk-trace-base): sync with main
mohitk05 Jan 27, 2023
b3e0307
feat(sdk-trace-base): [revert] sync with main
mohitk05 Jan 27, 2023
842143d
Merge branch 'main' into feat/span-dropped-counts
mohitk05 Jan 27, 2023
bab88a1
feat(sdk-trace-base): fix tests, make both counts truthy
mohitk05 Jan 28, 2023
33378f8
Merge branch 'feat/span-dropped-counts' of github.com:mohitk05/opente…
mohitk05 Jan 28, 2023
28666c6
Merge branch 'main' into feat/span-dropped-counts
mohitk05 Jan 30, 2023
17213bd
feat(sdk-trace-base): Update dropped counts type to number
mohitk05 Jan 31, 2023
81e35f6
Merge branch 'open-telemetry:main' into feat/span-dropped-counts
mohitk05 Jan 31, 2023
4eb895c
feat(sdk-trace-base): Merge branch 'feat/span-dropped-counts' of gith…
mohitk05 Jan 31, 2023
a8c1454
Merge branch 'main' into feat/span-dropped-counts
mohitk05 Feb 1, 2023
dc78fa3
feat(sdk-trace-base): Use exposed counts on ReadableSpan in jaeger an…
mohitk05 Feb 5, 2023
08d75e4
feat(sdk-trace-base): Merge branch 'feat/span-dropped-counts' of gith…
mohitk05 Feb 5, 2023
4a3105e
Merge branch 'main' into feat/span-dropped-counts
dyladan Feb 9, 2023
411c1cb
feat(sdk-trace-base): WIP - revert tsconfig, add new attribute limits
mohitk05 Feb 9, 2023
32300bf
feat(sdk-trace-base): Update attribute truncate method
mohitk05 Feb 9, 2023
5439f4e
Merge branch 'main' into feat/span-dropped-counts
dyladan Feb 24, 2023
0365435
Fix bad conflict resolution
dyladan Feb 24, 2023
8a486c7
Remove unused import
dyladan Feb 24, 2023
f9d935c
chore: lint
dyladan Feb 24, 2023
036190f
Merge branch 'main' into feat/span-dropped-counts
mohitk05 Feb 28, 2023
18d82c6
feat(sdk-trace-base): Remove dropped event attributes logic, add Jaeg…
mohitk05 Feb 28, 2023
f674906
feat(sdk-trace-base): Undo formatting in changelog
mohitk05 Feb 28, 2023
577b174
fix(changelog): Update experimental changelog
mohitk05 Feb 28, 2023
6dadccb
Update packages/opentelemetry-sdk-trace-base/src/Span.ts
mohitk05 Mar 1, 2023
1748267
Update packages/opentelemetry-sdk-trace-base/src/Span.ts
mohitk05 Mar 1, 2023
cc632ef
Merge branch 'main' into feat/span-dropped-counts
mohitk05 Mar 1, 2023
69b407f
fix(sdk-trace-base): Resolve review comments
mohitk05 Mar 1, 2023
85b2038
Merge branch 'main' into feat/span-dropped-counts
Flarna Mar 1, 2023
f260436
fix(sdk-trace-base): Fix failing tests
mohitk05 Mar 1, 2023
1db099c
Merge branch 'main' into feat/span-dropped-counts
mohitk05 Mar 1, 2023
0239413
fix(sdk-trace-base): make droppedAttributesCount on event optional
mohitk05 Mar 2, 2023
f40a11b
Merge branch 'main' into feat/span-dropped-counts
mohitk05 Mar 2, 2023
60bc89f
Merge branch 'main' into feat/span-dropped-counts
Flarna Mar 3, 2023
141172e
Merge branch 'main' into feat/span-dropped-counts
mohitk05 Mar 7, 2023
2221770
fix(changelog): Update changelog files
mohitk05 Mar 7, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
* feat: support TraceState in SamplingResult [#3530](https://github.com/open-telemetry/opentelemetry-js/pull/3530) @raphael-theriault-swi
* feat(sdk-trace-base): add diagnostic logging when spans are dropped [#3610](https://github.com/open-telemetry/opentelemetry-js/pull/3610) @neoeinstein
* feat: add unit to view instrument selection criteria [#3647](https://github.com/open-telemetry/opentelemetry-js/pull/3647) @jlabatut
* feat(tracing): expose dropped counts for attributes, events and links on span [#3576](https://github.com/open-telemetry/opentelemetry-js/pull/3576) @mohitk05

### :bug: (Bug Fix)

Expand Down
1 change: 1 addition & 0 deletions api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
### :rocket: (Enhancement)

* feat(api): add `getActiveBaggage` API [#3385](https://github.com/open-telemetry/opentelemetry-js/pull/3385)
* feat(api): add optional `droppedAttributesCount` property in the `Link` interface [#3576](https://github.com/open-telemetry/opentelemetry-js/pull/3576) @mohitk05

### :bug: (Bug Fix)

Expand Down
2 changes: 2 additions & 0 deletions api/src/trace/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ export interface Link {
context: SpanContext;
/** A set of {@link SpanAttributes} on the link. */
attributes?: SpanAttributes;
/** Count of attributes of the link that were dropped due to collection limits */
droppedAttributesCount?: number;
legendecas marked this conversation as resolved.
Show resolved Hide resolved
}
1 change: 1 addition & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ All notable changes to experimental packages in this project will be documented
* feat(sdk-node): install diag logger with OTEL_LOG_LEVEL [#3627](https://github.com/open-telemetry/opentelemetry-js/pull/3627) @legendecas
* feat(otlp-exporter-base): add retries [#3207](https://github.com/open-telemetry/opentelemetry-js/pull/3207) @svetlanabrennan
* feat(sdk-node): override IdGenerator when using NodeSDK [#3645](https://github.com/open-telemetry/opentelemetry-js/pull/3645) @haddasbronfman
* feat(otlp-transformer): expose dropped attributes, events and links counts on the transformed otlp span [#3576](https://github.com/open-telemetry/opentelemetry-js/pull/3576) @mohitk05

### :bug: (Bug Fix)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,34 @@ export const mockedReadableSpan: ReadableSpan = {
},
],
events: [
{ name: 'fetchStart', time: [1574120165, 429803070] },
{
name: 'fetchStart',
time: [1574120165, 429803070],
},
{
name: 'domainLookupStart',
time: [1574120165, 429803070],
},
{ name: 'domainLookupEnd', time: [1574120165, 429803070] },
{
name: 'domainLookupEnd',
time: [1574120165, 429803070],
},
{
name: 'connectStart',
time: [1574120165, 429803070],
},
{ name: 'connectEnd', time: [1574120165, 429803070] },
{
name: 'connectEnd',
time: [1574120165, 429803070],
},
{
name: 'requestStart',
time: [1574120165, 435513070],
},
{ name: 'responseStart', time: [1574120165, 436923070] },
{
name: 'responseStart',
time: [1574120165, 436923070],
},
{
name: 'responseEnd',
time: [1574120165, 438688070],
Expand All @@ -91,6 +103,9 @@ export const mockedReadableSpan: ReadableSpan = {
})
),
instrumentationLibrary: { name: 'default', version: '0.0.1' },
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
};

export function ensureExportedEventsAreCorrect(events: IEvent[]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,34 @@ export const mockedReadableSpan: ReadableSpan = {
},
],
events: [
{ name: 'fetchStart', time: [1574120165, 429803070] },
{
name: 'fetchStart',
time: [1574120165, 429803070],
},
{
name: 'domainLookupStart',
time: [1574120165, 429803070],
},
{ name: 'domainLookupEnd', time: [1574120165, 429803070] },
{
name: 'domainLookupEnd',
time: [1574120165, 429803070],
},
{
name: 'connectStart',
time: [1574120165, 429803070],
},
{ name: 'connectEnd', time: [1574120165, 429803070] },
{
name: 'connectEnd',
time: [1574120165, 429803070],
},
{
name: 'requestStart',
time: [1574120165, 435513070],
},
{ name: 'responseStart', time: [1574120165, 436923070] },
{
name: 'responseStart',
time: [1574120165, 436923070],
},
{
name: 'responseEnd',
time: [1574120165, 438688070],
Expand All @@ -102,6 +114,9 @@ export const mockedReadableSpan: ReadableSpan = {
})
),
instrumentationLibrary: { name: 'default', version: '0.0.1' },
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
};

export const mockedResources: Resource[] = [
Expand Down Expand Up @@ -142,6 +157,9 @@ export const basicTrace: ReadableSpan[] = [
duration: [0, 8885000],
resource: mockedResources[0],
instrumentationLibrary: mockedInstrumentationLibraries[0],
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
},
{
name: 'span2',
Expand All @@ -164,6 +182,9 @@ export const basicTrace: ReadableSpan[] = [
duration: [0, 8775000],
resource: mockedResources[0],
instrumentationLibrary: mockedInstrumentationLibraries[0],
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
},
{
name: 'span3',
Expand All @@ -186,6 +207,9 @@ export const basicTrace: ReadableSpan[] = [
duration: [0, 8775000],
resource: mockedResources[0],
instrumentationLibrary: mockedInstrumentationLibraries[0],
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,34 @@ export const mockedReadableSpan: ReadableSpan = {
},
],
events: [
{ name: 'fetchStart', time: [1574120165, 429803070] },
{
name: 'fetchStart',
time: [1574120165, 429803070],
},
{
name: 'domainLookupStart',
time: [1574120165, 429803070],
},
{ name: 'domainLookupEnd', time: [1574120165, 429803070] },
{
name: 'domainLookupEnd',
time: [1574120165, 429803070],
},
{
name: 'connectStart',
time: [1574120165, 429803070],
},
{ name: 'connectEnd', time: [1574120165, 429803070] },
{
name: 'connectEnd',
time: [1574120165, 429803070],
},
{
name: 'requestStart',
time: [1574120165, 435513070],
},
{ name: 'responseStart', time: [1574120165, 436923070] },
{
name: 'responseStart',
time: [1574120165, 436923070],
},
{
name: 'responseEnd',
time: [1574120165, 438688070],
Expand All @@ -87,6 +99,9 @@ export const mockedReadableSpan: ReadableSpan = {
cost: 112.12,
}),
instrumentationLibrary: { name: 'default', version: '0.0.1' },
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
};

export function ensureProtoEventsAreCorrect(events: IEvent[]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,34 @@ export const mockedReadableSpan: ReadableSpan = {
},
],
events: [
{ name: 'fetchStart', time: [1574120165, 429803070] },
{
name: 'fetchStart',
time: [1574120165, 429803070],
},
{
name: 'domainLookupStart',
time: [1574120165, 429803070],
},
{ name: 'domainLookupEnd', time: [1574120165, 429803070] },
{
name: 'domainLookupEnd',
time: [1574120165, 429803070],
},
{
name: 'connectStart',
time: [1574120165, 429803070],
},
{ name: 'connectEnd', time: [1574120165, 429803070] },
{
name: 'connectEnd',
time: [1574120165, 429803070],
},
{
name: 'requestStart',
time: [1574120165, 435513070],
},
{ name: 'responseStart', time: [1574120165, 436923070] },
{
name: 'responseStart',
time: [1574120165, 436923070],
},
{
name: 'responseEnd',
time: [1574120165, 438688070],
Expand All @@ -91,6 +103,9 @@ export const mockedReadableSpan: ReadableSpan = {
})
),
instrumentationLibrary: { name: 'default', version: '0.0.1' },
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
};

export function ensureExportedEventsAreCorrect(events: IEvent[]) {
Expand Down
10 changes: 5 additions & 5 deletions experimental/packages/otlp-transformer/src/trace/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ export function sdkSpanToOtlpSpan(span: ReadableSpan, useHex?: boolean): ISpan {
startTimeUnixNano: hrTimeToNanoseconds(span.startTime),
endTimeUnixNano: hrTimeToNanoseconds(span.endTime),
attributes: toAttributes(span.attributes),
droppedAttributesCount: 0,
droppedAttributesCount: span.droppedAttributesCount,
events: span.events.map(toOtlpSpanEvent),
droppedEventsCount: 0,
droppedEventsCount: span.droppedEventsCount,
status: {
// API and proto enums share the same values
code: status.code as unknown as EStatusCode,
message: status.message,
},
links: span.links.map(link => toOtlpLink(link, useHex)),
droppedLinksCount: 0,
droppedLinksCount: span.droppedLinksCount,
};
}

Expand All @@ -62,7 +62,7 @@ export function toOtlpLink(link: Link, useHex?: boolean): ILink {
? link.context.traceId
: core.hexToBase64(link.context.traceId),
traceState: link.context.traceState?.serialize(),
droppedAttributesCount: 0,
droppedAttributesCount: link.droppedAttributesCount || 0,
};
}

Expand All @@ -73,6 +73,6 @@ export function toOtlpSpanEvent(timedEvent: TimedEvent): IEvent {
: [],
name: timedEvent.name,
timeUnixNano: hrTimeToNanoseconds(timedEvent.time),
droppedAttributesCount: 0,
droppedAttributesCount: timedEvent.droppedAttributesCount || 0,
Flarna marked this conversation as resolved.
Show resolved Hide resolved
};
}
3 changes: 3 additions & 0 deletions experimental/packages/otlp-transformer/test/trace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ describe('Trace', () => {
status: {
code: SpanStatusCode.OK,
},
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
};
});

Expand Down
9 changes: 9 additions & 0 deletions packages/opentelemetry-core/src/utils/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const ENVIRONMENT_NUMBERS_KEYS = [
'OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT',
'OTEL_SPAN_EVENT_COUNT_LIMIT',
'OTEL_SPAN_LINK_COUNT_LIMIT',
'OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT',
'OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT',
'OTEL_EXPORTER_OTLP_TIMEOUT',
'OTEL_EXPORTER_OTLP_TRACES_TIMEOUT',
'OTEL_EXPORTER_OTLP_METRICS_TIMEOUT',
Expand Down Expand Up @@ -131,6 +133,9 @@ export const DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT = Infinity;

export const DEFAULT_ATTRIBUTE_COUNT_LIMIT = 128;

export const DEFAULT_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT = 128;
export const DEFAULT_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT = 128;

/**
* Default environment variables
*/
Expand Down Expand Up @@ -172,6 +177,10 @@ export const DEFAULT_ENVIRONMENT: Required<ENVIRONMENT> = {
OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT: DEFAULT_ATTRIBUTE_COUNT_LIMIT,
OTEL_SPAN_EVENT_COUNT_LIMIT: 128,
OTEL_SPAN_LINK_COUNT_LIMIT: 128,
OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT:
DEFAULT_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT,
OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT:
DEFAULT_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT,
OTEL_TRACES_EXPORTER: '',
OTEL_TRACES_SAMPLER: TracesSamplerValues.ParentBasedAlwaysOn,
OTEL_TRACES_SAMPLER_ARG: '',
Expand Down
30 changes: 30 additions & 0 deletions packages/opentelemetry-exporter-jaeger/src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,30 @@ export function spanToThrift(span: ReadableSpan): ThriftSpan {
});
}

/* Add droppedAttributesCount as a tag */
if (span.droppedAttributesCount) {
tags.push({
key: 'otel.dropped_attributes_count',
value: toTagValue(span.droppedAttributesCount),
});
}

/* Add droppedEventsCount as a tag */
if (span.droppedEventsCount) {
tags.push({
key: 'otel.dropped_events_count',
value: toTagValue(span.droppedEventsCount),
});
}
dyladan marked this conversation as resolved.
Show resolved Hide resolved

/* Add droppedLinksCount as a tag */
if (span.droppedLinksCount) {
tags.push({
key: 'otel.dropped_links_count',
value: toTagValue(span.droppedLinksCount),
});
}
dyladan marked this conversation as resolved.
Show resolved Hide resolved

const spanTags: ThriftTag[] = ThriftUtils.getThriftTags(tags);

const logs = span.events.map((event): Log => {
Expand All @@ -96,6 +120,12 @@ export function spanToThrift(span: ReadableSpan): ThriftSpan {
fields.push({ key: attr, value: toTagValue(attrs[attr]) })
);
}
if (event.droppedAttributesCount) {
fields.push({
key: 'otel.event.dropped_attributes_count',
value: event.droppedAttributesCount,
});
}
return { timestamp: hrTimeToMilliseconds(event.time), fields };
});
const spanLogs: ThriftLog[] = ThriftUtils.getThriftLogs(logs);
Expand Down
3 changes: 3 additions & 0 deletions packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ describe('JaegerExporter', () => {
name: 'default',
version: '0.0.1',
},
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
};
describe('constructor', () => {
afterEach(() => {
Expand Down
Loading