Skip to content

Commit

Permalink
Merge branch 'open-telemetry:main' into MSNev/SandboxFixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MSNev authored Mar 8, 2023
2 parents ba2f1f7 + 48ecf22 commit 33b68e0
Show file tree
Hide file tree
Showing 25 changed files with 295 additions and 62 deletions.
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;
}
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
23 changes: 19 additions & 4 deletions experimental/packages/exporter-trace-otlp-grpc/test/traceHelper.ts
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
32 changes: 28 additions & 4 deletions experimental/packages/exporter-trace-otlp-http/test/traceHelper.ts
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
23 changes: 19 additions & 4 deletions experimental/packages/otlp-grpc-exporter-base/test/traceHelper.ts
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,
};
}
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),
});
}

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

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

0 comments on commit 33b68e0

Please sign in to comment.