Skip to content

Commit 48ecf22

Browse files
mohitk05dyladanFlarna
authored
feat(sdk-trace-base): add dropped attributes and events count on span (#3576)
* feat(sdk-trace-base): add dropped attributes and events count on span * feat(sdk-trace-base): sync with main * feat(sdk-trace-base): [revert] sync with main * feat(sdk-trace-base): fix tests, make both counts truthy * feat(sdk-trace-base): Update dropped counts type to number * feat(sdk-trace-base): Use exposed counts on ReadableSpan in jaeger and zipkin exporters * feat(sdk-trace-base): WIP - revert tsconfig, add new attribute limits * feat(sdk-trace-base): Update attribute truncate method * Fix bad conflict resolution * Remove unused import * chore: lint * feat(sdk-trace-base): Remove dropped event attributes logic, add Jaeger field * feat(sdk-trace-base): Undo formatting in changelog * fix(changelog): Update experimental changelog * Update packages/opentelemetry-sdk-trace-base/src/Span.ts Co-authored-by: Gerhard Stöbich <[email protected]> * Update packages/opentelemetry-sdk-trace-base/src/Span.ts Co-authored-by: Gerhard Stöbich <[email protected]> * fix(sdk-trace-base): Resolve review comments * fix(sdk-trace-base): Fix failing tests * fix(sdk-trace-base): make droppedAttributesCount on event optional * fix(changelog): Update changelog files --------- Co-authored-by: Daniel Dyla <[email protected]> Co-authored-by: Gerhard Stöbich <[email protected]>
1 parent 95bf6fc commit 48ecf22

File tree

25 files changed

+295
-62
lines changed

25 files changed

+295
-62
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
2020
* feat: support TraceState in SamplingResult [#3530](https://github.com/open-telemetry/opentelemetry-js/pull/3530) @raphael-theriault-swi
2121
* feat(sdk-trace-base): add diagnostic logging when spans are dropped [#3610](https://github.com/open-telemetry/opentelemetry-js/pull/3610) @neoeinstein
2222
* feat: add unit to view instrument selection criteria [#3647](https://github.com/open-telemetry/opentelemetry-js/pull/3647) @jlabatut
23+
* feat(tracing): expose dropped counts for attributes, events and links on span [#3576](https://github.com/open-telemetry/opentelemetry-js/pull/3576) @mohitk05
2324

2425
### :bug: (Bug Fix)
2526

api/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
1515
### :rocket: (Enhancement)
1616

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

1920
### :bug: (Bug Fix)
2021

api/src/trace/link.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,6 @@ export interface Link {
3737
context: SpanContext;
3838
/** A set of {@link SpanAttributes} on the link. */
3939
attributes?: SpanAttributes;
40+
/** Count of attributes of the link that were dropped due to collection limits */
41+
droppedAttributesCount?: number;
4042
}

experimental/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ All notable changes to experimental packages in this project will be documented
1616
* feat(sdk-node): install diag logger with OTEL_LOG_LEVEL [#3627](https://github.com/open-telemetry/opentelemetry-js/pull/3627) @legendecas
1717
* feat(otlp-exporter-base): add retries [#3207](https://github.com/open-telemetry/opentelemetry-js/pull/3207) @svetlanabrennan
1818
* feat(sdk-node): override IdGenerator when using NodeSDK [#3645](https://github.com/open-telemetry/opentelemetry-js/pull/3645) @haddasbronfman
19+
* 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
1920

2021
### :bug: (Bug Fix)
2122

experimental/packages/exporter-trace-otlp-grpc/test/traceHelper.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,34 @@ export const mockedReadableSpan: ReadableSpan = {
6161
},
6262
],
6363
events: [
64-
{ name: 'fetchStart', time: [1574120165, 429803070] },
64+
{
65+
name: 'fetchStart',
66+
time: [1574120165, 429803070],
67+
},
6568
{
6669
name: 'domainLookupStart',
6770
time: [1574120165, 429803070],
6871
},
69-
{ name: 'domainLookupEnd', time: [1574120165, 429803070] },
72+
{
73+
name: 'domainLookupEnd',
74+
time: [1574120165, 429803070],
75+
},
7076
{
7177
name: 'connectStart',
7278
time: [1574120165, 429803070],
7379
},
74-
{ name: 'connectEnd', time: [1574120165, 429803070] },
80+
{
81+
name: 'connectEnd',
82+
time: [1574120165, 429803070],
83+
},
7584
{
7685
name: 'requestStart',
7786
time: [1574120165, 435513070],
7887
},
79-
{ name: 'responseStart', time: [1574120165, 436923070] },
88+
{
89+
name: 'responseStart',
90+
time: [1574120165, 436923070],
91+
},
8092
{
8193
name: 'responseEnd',
8294
time: [1574120165, 438688070],
@@ -91,6 +103,9 @@ export const mockedReadableSpan: ReadableSpan = {
91103
})
92104
),
93105
instrumentationLibrary: { name: 'default', version: '0.0.1' },
106+
droppedAttributesCount: 0,
107+
droppedEventsCount: 0,
108+
droppedLinksCount: 0,
94109
};
95110

96111
export function ensureExportedEventsAreCorrect(events: IEvent[]) {

experimental/packages/exporter-trace-otlp-http/test/traceHelper.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,34 @@ export const mockedReadableSpan: ReadableSpan = {
7272
},
7373
],
7474
events: [
75-
{ name: 'fetchStart', time: [1574120165, 429803070] },
75+
{
76+
name: 'fetchStart',
77+
time: [1574120165, 429803070],
78+
},
7679
{
7780
name: 'domainLookupStart',
7881
time: [1574120165, 429803070],
7982
},
80-
{ name: 'domainLookupEnd', time: [1574120165, 429803070] },
83+
{
84+
name: 'domainLookupEnd',
85+
time: [1574120165, 429803070],
86+
},
8187
{
8288
name: 'connectStart',
8389
time: [1574120165, 429803070],
8490
},
85-
{ name: 'connectEnd', time: [1574120165, 429803070] },
91+
{
92+
name: 'connectEnd',
93+
time: [1574120165, 429803070],
94+
},
8695
{
8796
name: 'requestStart',
8897
time: [1574120165, 435513070],
8998
},
90-
{ name: 'responseStart', time: [1574120165, 436923070] },
99+
{
100+
name: 'responseStart',
101+
time: [1574120165, 436923070],
102+
},
91103
{
92104
name: 'responseEnd',
93105
time: [1574120165, 438688070],
@@ -102,6 +114,9 @@ export const mockedReadableSpan: ReadableSpan = {
102114
})
103115
),
104116
instrumentationLibrary: { name: 'default', version: '0.0.1' },
117+
droppedAttributesCount: 0,
118+
droppedEventsCount: 0,
119+
droppedLinksCount: 0,
105120
};
106121

107122
export const mockedResources: Resource[] = [
@@ -142,6 +157,9 @@ export const basicTrace: ReadableSpan[] = [
142157
duration: [0, 8885000],
143158
resource: mockedResources[0],
144159
instrumentationLibrary: mockedInstrumentationLibraries[0],
160+
droppedAttributesCount: 0,
161+
droppedEventsCount: 0,
162+
droppedLinksCount: 0,
145163
},
146164
{
147165
name: 'span2',
@@ -164,6 +182,9 @@ export const basicTrace: ReadableSpan[] = [
164182
duration: [0, 8775000],
165183
resource: mockedResources[0],
166184
instrumentationLibrary: mockedInstrumentationLibraries[0],
185+
droppedAttributesCount: 0,
186+
droppedEventsCount: 0,
187+
droppedLinksCount: 0,
167188
},
168189
{
169190
name: 'span3',
@@ -186,6 +207,9 @@ export const basicTrace: ReadableSpan[] = [
186207
duration: [0, 8775000],
187208
resource: mockedResources[0],
188209
instrumentationLibrary: mockedInstrumentationLibraries[0],
210+
droppedAttributesCount: 0,
211+
droppedEventsCount: 0,
212+
droppedLinksCount: 0,
189213
},
190214
];
191215

experimental/packages/exporter-trace-otlp-proto/test/traceHelper.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,34 @@ export const mockedReadableSpan: ReadableSpan = {
5959
},
6060
],
6161
events: [
62-
{ name: 'fetchStart', time: [1574120165, 429803070] },
62+
{
63+
name: 'fetchStart',
64+
time: [1574120165, 429803070],
65+
},
6366
{
6467
name: 'domainLookupStart',
6568
time: [1574120165, 429803070],
6669
},
67-
{ name: 'domainLookupEnd', time: [1574120165, 429803070] },
70+
{
71+
name: 'domainLookupEnd',
72+
time: [1574120165, 429803070],
73+
},
6874
{
6975
name: 'connectStart',
7076
time: [1574120165, 429803070],
7177
},
72-
{ name: 'connectEnd', time: [1574120165, 429803070] },
78+
{
79+
name: 'connectEnd',
80+
time: [1574120165, 429803070],
81+
},
7382
{
7483
name: 'requestStart',
7584
time: [1574120165, 435513070],
7685
},
77-
{ name: 'responseStart', time: [1574120165, 436923070] },
86+
{
87+
name: 'responseStart',
88+
time: [1574120165, 436923070],
89+
},
7890
{
7991
name: 'responseEnd',
8092
time: [1574120165, 438688070],
@@ -87,6 +99,9 @@ export const mockedReadableSpan: ReadableSpan = {
8799
cost: 112.12,
88100
}),
89101
instrumentationLibrary: { name: 'default', version: '0.0.1' },
102+
droppedAttributesCount: 0,
103+
droppedEventsCount: 0,
104+
droppedLinksCount: 0,
90105
};
91106

92107
export function ensureProtoEventsAreCorrect(events: IEvent[]) {

experimental/packages/otlp-grpc-exporter-base/test/traceHelper.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,34 @@ export const mockedReadableSpan: ReadableSpan = {
6161
},
6262
],
6363
events: [
64-
{ name: 'fetchStart', time: [1574120165, 429803070] },
64+
{
65+
name: 'fetchStart',
66+
time: [1574120165, 429803070],
67+
},
6568
{
6669
name: 'domainLookupStart',
6770
time: [1574120165, 429803070],
6871
},
69-
{ name: 'domainLookupEnd', time: [1574120165, 429803070] },
72+
{
73+
name: 'domainLookupEnd',
74+
time: [1574120165, 429803070],
75+
},
7076
{
7177
name: 'connectStart',
7278
time: [1574120165, 429803070],
7379
},
74-
{ name: 'connectEnd', time: [1574120165, 429803070] },
80+
{
81+
name: 'connectEnd',
82+
time: [1574120165, 429803070],
83+
},
7584
{
7685
name: 'requestStart',
7786
time: [1574120165, 435513070],
7887
},
79-
{ name: 'responseStart', time: [1574120165, 436923070] },
88+
{
89+
name: 'responseStart',
90+
time: [1574120165, 436923070],
91+
},
8092
{
8193
name: 'responseEnd',
8294
time: [1574120165, 438688070],
@@ -91,6 +103,9 @@ export const mockedReadableSpan: ReadableSpan = {
91103
})
92104
),
93105
instrumentationLibrary: { name: 'default', version: '0.0.1' },
106+
droppedAttributesCount: 0,
107+
droppedEventsCount: 0,
108+
droppedLinksCount: 0,
94109
};
95110

96111
export function ensureExportedEventsAreCorrect(events: IEvent[]) {

experimental/packages/otlp-transformer/src/trace/internal.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ export function sdkSpanToOtlpSpan(span: ReadableSpan, useHex?: boolean): ISpan {
3939
startTimeUnixNano: hrTimeToNanoseconds(span.startTime),
4040
endTimeUnixNano: hrTimeToNanoseconds(span.endTime),
4141
attributes: toAttributes(span.attributes),
42-
droppedAttributesCount: 0,
42+
droppedAttributesCount: span.droppedAttributesCount,
4343
events: span.events.map(toOtlpSpanEvent),
44-
droppedEventsCount: 0,
44+
droppedEventsCount: span.droppedEventsCount,
4545
status: {
4646
// API and proto enums share the same values
4747
code: status.code as unknown as EStatusCode,
4848
message: status.message,
4949
},
5050
links: span.links.map(link => toOtlpLink(link, useHex)),
51-
droppedLinksCount: 0,
51+
droppedLinksCount: span.droppedLinksCount,
5252
};
5353
}
5454

@@ -62,7 +62,7 @@ export function toOtlpLink(link: Link, useHex?: boolean): ILink {
6262
? link.context.traceId
6363
: core.hexToBase64(link.context.traceId),
6464
traceState: link.context.traceState?.serialize(),
65-
droppedAttributesCount: 0,
65+
droppedAttributesCount: link.droppedAttributesCount || 0,
6666
};
6767
}
6868

@@ -73,6 +73,6 @@ export function toOtlpSpanEvent(timedEvent: TimedEvent): IEvent {
7373
: [],
7474
name: timedEvent.name,
7575
timeUnixNano: hrTimeToNanoseconds(timedEvent.time),
76-
droppedAttributesCount: 0,
76+
droppedAttributesCount: timedEvent.droppedAttributesCount || 0,
7777
};
7878
}

experimental/packages/otlp-transformer/test/trace.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ describe('Trace', () => {
178178
status: {
179179
code: SpanStatusCode.OK,
180180
},
181+
droppedAttributesCount: 0,
182+
droppedEventsCount: 0,
183+
droppedLinksCount: 0,
181184
};
182185
});
183186

0 commit comments

Comments
 (0)