Skip to content

Commit c25db0c

Browse files
authored
OpenTelemetry Exporter classes/method description and internal tagging (Azure#13836)
* Adding documentation description and internal tag * Lint * Adding doc for service API version enum * Lint * Addressing comments
1 parent 745290d commit c25db0c

File tree

20 files changed

+311
-15
lines changed

20 files changed

+311
-15
lines changed

sdk/monitor/monitor-opentelemetry-exporter/review/monitor-opentelemetry-exporter.api.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,21 @@ import { ExportResult } from '@opentelemetry/core';
88
import { ReadableSpan } from '@opentelemetry/tracing';
99
import { SpanExporter } from '@opentelemetry/tracing';
1010

11-
// @public (undocumented)
11+
// @public
1212
export interface AzureExporterConfig {
13-
// (undocumented)
1413
apiVersion?: ServiceApiVersion;
15-
// (undocumented)
1614
connectionString?: string;
1715
}
1816

19-
// @public (undocumented)
17+
// @public
2018
export class AzureMonitorTraceExporter implements SpanExporter {
2119
constructor(options?: AzureExporterConfig);
22-
// (undocumented)
2320
export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): Promise<void>;
24-
// (undocumented)
2521
shutdown(): Promise<void>;
2622
}
2723

28-
// @public (undocumented)
24+
// @public
2925
export enum ServiceApiVersion {
30-
// (undocumented)
3126
V2 = "2020-09-15_Preview"
3227
}
3328

sdk/monitor/monitor-opentelemetry-exporter/src/Declarations/Constants.ts

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,51 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33

4+
/**
5+
* Azure service API version.
6+
*/
47
export enum ServiceApiVersion {
8+
/**
9+
* V2 Version
10+
*/
511
V2 = "2020-09-15_Preview"
612
}
713

14+
/**
15+
* Default Breeze endpoint.
16+
* @internal
17+
*/
818
export const DEFAULT_BREEZE_ENDPOINT = "https://dc.services.visualstudio.com";
19+
/**
20+
* Default Breeze API version.
21+
* @internal
22+
*/
923
export const DEFAULT_BREEZE_API_VERSION = ServiceApiVersion.V2;
24+
/**
25+
* Default Live Metrics endpoint.
26+
* @internal
27+
*/
1028
export const DEFAULT_LIVEMETRICS_ENDPOINT = "https://rt.services.visualstudio.com";
29+
/**
30+
* Default Live Metrics host.
31+
* @internal
32+
*/
1133
export const DEFAULT_LIVEMETRICS_HOST = "rt.services.visualstudio.com";
34+
/**
35+
* Connection string environment variable name.
36+
* @internal
37+
*/
1238
export const ENV_CONNECTION_STRING = "APPLICATIONINSIGHTS_CONNECTION_STRING";
39+
/**
40+
* Instrumentation key environment variable name.
41+
* @internal
42+
*/
1343
export const ENV_INSTRUMENTATION_KEY = "APPINSIGHTS_INSTRUMENTATIONKEY";
1444

45+
/**
46+
* QuickPulse metric counter names.
47+
* @internal
48+
*/
1549
export enum QuickPulseCounter {
1650
// Memory
1751
COMMITTED_BYTES = "\\Memory\\Committed Bytes",
@@ -33,6 +67,10 @@ export enum QuickPulseCounter {
3367
EXCEPTION_RATE = "\\ApplicationInsights\\Exceptions/Sec"
3468
}
3569

70+
/**
71+
* Performance metric counter names.
72+
* @internal
73+
*/
3674
export enum PerformanceCounter {
3775
// Memory
3876
PRIVATE_BYTES = "\\Process(??APP_WIN32_PROC??)\\Private Bytes",
@@ -49,6 +87,7 @@ export enum PerformanceCounter {
4987

5088
/**
5189
* Map a PerformanceCounter/QuickPulseCounter to a QuickPulseCounter. If no mapping exists, mapping is *undefined*
90+
* @internal
5291
*/
5392
export const PerformanceToQuickPulseCounter: { [key: string]: QuickPulseCounter } = {
5493
[PerformanceCounter.PROCESSOR_TIME]: QuickPulseCounter.PROCESSOR_TIME,
@@ -64,8 +103,10 @@ export const PerformanceToQuickPulseCounter: { [key: string]: QuickPulseCounter
64103
[QuickPulseCounter.EXCEPTION_RATE]: QuickPulseCounter.EXCEPTION_RATE
65104
};
66105

67-
// Note: Explicitly define these types instead of using enum due to
68-
// potential 'export enum' issues with typescript < 2.0.
106+
/**
107+
* QuickPulse document types.
108+
* @internal
109+
*/
69110
export type QuickPulseDocumentType =
70111
| "Event"
71112
| "Exception"
@@ -74,6 +115,10 @@ export type QuickPulseDocumentType =
74115
| "Request"
75116
| "RemoteDependency"
76117
| "Availability";
118+
/**
119+
* QuickPulse telemetry types.
120+
* @internal
121+
*/
77122
export type QuickPulseType =
78123
| "EventTelemetryDocument"
79124
| "ExceptionTelemetryDocument"
@@ -83,7 +128,10 @@ export type QuickPulseType =
83128
| "DependencyTelemetryDocument"
84129
| "AvailabilityTelemetryDocument";
85130

86-
// OpenTelemetry Span Attributes
131+
/**
132+
* OpenTelemetry Span Attributes.
133+
* @internal
134+
*/
87135
export const SpanAttribute = {
88136
// HTTP
89137
HttpHost: "http.host",
@@ -98,6 +146,10 @@ export const SpanAttribute = {
98146
GrpcService: "rpc.service" // rpc not grpc
99147
};
100148

149+
/**
150+
* OpenTelemetry dependency type names.
151+
* @internal
152+
*/
101153
export const DependencyTypeName = {
102154
Grpc: "GRPC",
103155
Http: "HTTP",

sdk/monitor/monitor-opentelemetry-exporter/src/Declarations/Contracts/Constants.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33

44
/**
55
* Subset of Connection String fields which this SDK can parse. Lower-typecased to
6-
* allow for case-insensitivity across field names
6+
* allow for case-insensitivity across field names.
7+
* @internal
78
*/
89
export type ConnectionString = { [key in ConnectionStringKey]?: string };
910

11+
/**
12+
* ConnectionString keys.
13+
* @internal
14+
*/
1015
export type ConnectionStringKey =
1116
| "authorization"
1217
| "instrumentationkey"

sdk/monitor/monitor-opentelemetry-exporter/src/config.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,25 @@ import {
1010
const DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS = 60_000;
1111
const DEFAULT_MAX_CONSECUTIVE_FAILURES_BEFORE_WARNING = 10;
1212

13+
/**
14+
* Provides configuration options for AzureMonitorTraceExporter.
15+
*/
1316
export interface AzureExporterConfig {
14-
// Setup String
17+
/**
18+
* Azure Monitor Connection String, if not provided the exporter will try to use environment variable APPLICATIONINSIGHTS_CONNECTION_STRING
19+
* Ex: "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://dc.services.visualstudio.com"
20+
*/
1521
connectionString?: string;
16-
// Azure service API version
22+
/**
23+
* Azure service API version.
24+
*/
1725
apiVersion?: ServiceApiVersion;
1826
}
1927

28+
/**
29+
* Internal Azure exporter configuration
30+
* @internal
31+
*/
2032
export interface AzureExporterInternalConfig {
2133
instrumentationKey: string;
2234
batchSendRetryIntervalMs: number;
@@ -25,6 +37,10 @@ export interface AzureExporterInternalConfig {
2537
apiVersion: ServiceApiVersion;
2638
}
2739

40+
/**
41+
* Internal default Azure exporter configuration
42+
* @internal
43+
*/
2844
export const DEFAULT_EXPORTER_CONFIG: AzureExporterInternalConfig = {
2945
instrumentationKey: "",
3046
endpointUrl: DEFAULT_BREEZE_ENDPOINT,

sdk/monitor/monitor-opentelemetry-exporter/src/export/trace.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import { ENV_CONNECTION_STRING } from "../Declarations/Constants";
1818
import { TelemetryItem as Envelope } from "../generated";
1919
import { readableSpanToEnvelope } from "../utils/spanUtils";
2020

21+
/**
22+
* Azure Monitor OpenTelemetry Trace Exporter.
23+
*/
2124
export class AzureMonitorTraceExporter implements SpanExporter {
2225
private readonly _persister: PersistentStorage;
2326

@@ -27,6 +30,10 @@ export class AzureMonitorTraceExporter implements SpanExporter {
2730

2831
private readonly _options: AzureExporterInternalConfig;
2932

33+
/**
34+
* Initializes a new instance of the AzureMonitorTraceExporter class.
35+
* @param AzureExporterConfig - Exporter configuration.
36+
*/
3037
constructor(options: AzureExporterConfig = {}) {
3138
const connectionString = options.connectionString || process.env[ENV_CONNECTION_STRING];
3239
this._options = {
@@ -122,6 +129,11 @@ export class AzureMonitorTraceExporter implements SpanExporter {
122129
}
123130
}
124131

132+
/**
133+
* Export OpenTelemetry spans.
134+
* @param spans - Spans to export.
135+
* @param resultCallback - Result callback.
136+
*/
125137
async export(
126138
spans: ReadableSpan[],
127139
resultCallback: (result: ExportResult) => void
@@ -133,6 +145,9 @@ export class AzureMonitorTraceExporter implements SpanExporter {
133145
resultCallback(await this.exportEnvelopes(envelopes));
134146
}
135147

148+
/**
149+
* Shutdown AzureMonitorTraceExporter.
150+
*/
136151
async shutdown(): Promise<void> {
137152
diag.info("Azure Monitor Trace Exporter shutting down");
138153
return this._sender.shutdown();

sdk/monitor/monitor-opentelemetry-exporter/src/platform/nodejs/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33

4+
/**
5+
* SDK info
6+
* @internal
7+
*/
48
export const SDK_INFO = {
59
NAME: "opentelemetry",
610
RUNTIME: "node",

sdk/monitor/monitor-opentelemetry-exporter/src/platform/nodejs/context/context.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ type PackageJson = { version: string };
1414

1515
let instance: Context | null = null;
1616

17+
/**
18+
* Azure Telemetry context.
19+
* @internal
20+
*/
1721
export class Context {
1822
public tags: Tags;
1923

@@ -145,6 +149,10 @@ export class Context {
145149
}
146150
}
147151

152+
/**
153+
* Singleton Context instance.
154+
* @internal
155+
*/
148156
export function getInstance(exporterPrefix?: string, appPrefix?: string): Context {
149157
if (!instance) {
150158
instance = new Context(exporterPrefix, appPrefix);

sdk/monitor/monitor-opentelemetry-exporter/src/platform/nodejs/httpSender.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import {
1010
} from "../../generated";
1111
import { AzureExporterInternalConfig } from "../../config";
1212

13+
/**
14+
* Exporter HTTP sender class
15+
* @internal
16+
*/
1317
export class HttpSender implements Sender {
1418
private readonly _appInsightsClient: ApplicationInsightsClient;
1519
private _appInsightsClientOptions: ApplicationInsightsClientOptionalParams;
@@ -25,6 +29,10 @@ export class HttpSender implements Sender {
2529
});
2630
}
2731

32+
/**
33+
* Send Azure envelopes
34+
* @internal
35+
*/
2836
async send(envelopes: Envelope[]): Promise<SenderResult> {
2937
try {
3038
const { _response: res } = await this._appInsightsClient.track(envelopes);
@@ -34,6 +42,10 @@ export class HttpSender implements Sender {
3442
}
3543
}
3644

45+
/**
46+
* Shutdown sender
47+
* @internal
48+
*/
3749
async shutdown(): Promise<void> {
3850
diag.info("HttpSender shutting down");
3951
}

sdk/monitor/monitor-opentelemetry-exporter/src/platform/nodejs/persist/fileSystemHelpers.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const mkdirAsync = promisify(fs.mkdir);
1212

1313
/**
1414
* Computes the size (in bytes) of all files in a directory at the root level. Asynchronously.
15+
* @internal
1516
*/
1617
export const getShallowDirectorySize = async (directory: string): Promise<number> => {
1718
// Get the directory listing
@@ -30,6 +31,10 @@ export const getShallowDirectorySize = async (directory: string): Promise<number
3031
return totalSize;
3132
};
3233

34+
/**
35+
* Validate directory exists.
36+
* @internal
37+
*/
3338
export const confirmDirExists = async (directory: string): Promise<void> => {
3439
try {
3540
const stats = await lstatAsync(directory);

sdk/monitor/monitor-opentelemetry-exporter/src/platform/nodejs/persist/fileSystemPersist.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ const readFileAsync = promisify(fs.readFile);
1616
const unlinkAsync = promisify(fs.unlink);
1717
const writeFileAsync = promisify(fs.writeFile);
1818

19+
/**
20+
* File system persist class.
21+
* @internal
22+
*/
1923
export class FileSystemPersist implements PersistentStorage {
2024
static TEMPDIR_PREFIX = "ot-azure-exporter-";
2125

0 commit comments

Comments
 (0)