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

[Beta] Updating Azure Function Hook logic #1071

Merged
merged 5 commits into from
Feb 7, 2023
Merged
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
531 changes: 193 additions & 338 deletions package-lock.json

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
},
"devDependencies": {
"@azure/functions": "^3.2.0",
"@types/long": "^4.0.2",
"@types/microsoft__typescript-etw": "^0.1.0",
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
Expand All @@ -70,20 +71,19 @@
"@azure/identity": "^3.1.3",
"@azure/monitor-opentelemetry-exporter": "^1.0.0-beta.11",
"@azure/opentelemetry-instrumentation-azure-sdk": "^1.0.0-beta.1",
"@opentelemetry/api": "^1.2.0",
"@opentelemetry/api-metrics": "^0.32.0",
"@opentelemetry/core": "^1.7.0",
"@opentelemetry/instrumentation": "^0.33.0",
"@opentelemetry/instrumentation-http": "^0.33.0",
"@opentelemetry/instrumentation-mongodb": "^0.32.0",
"@opentelemetry/instrumentation-mysql": "^0.31.0",
"@opentelemetry/instrumentation-pg": "^0.31.0",
"@opentelemetry/instrumentation-redis": "^0.33.0",
"@opentelemetry/instrumentation-redis-4": "^0.32.0",
"@opentelemetry/sdk-metrics": "^0.33.0",
"@opentelemetry/sdk-trace-base": "^1.7.0",
"@opentelemetry/sdk-trace-node": "^1.7.0",
"@opentelemetry/semantic-conventions": "^1.7.0",
"@opentelemetry/api": "^1.4.0",
"@opentelemetry/core": "^1.9.1",
"@opentelemetry/instrumentation": "^0.35.1",
"@opentelemetry/instrumentation-http": "^0.35.1",
"@opentelemetry/instrumentation-mongodb": "^0.34.0",
"@opentelemetry/instrumentation-mysql": "^0.32.0",
"@opentelemetry/instrumentation-pg": "^0.34.0",
"@opentelemetry/instrumentation-redis": "^0.34.1",
"@opentelemetry/instrumentation-redis-4": "^0.34.1",
"@opentelemetry/sdk-metrics": "^1.9.1",
"@opentelemetry/sdk-trace-base": "^1.9.1",
"@opentelemetry/sdk-trace-node": "^1.9.1",
"@opentelemetry/semantic-conventions": "^1.9.1",
"diagnostic-channel": "1.1.0",
"diagnostic-channel-publishers": "1.0.4",
"semver": "^7.3.5"
Expand Down
8 changes: 4 additions & 4 deletions src/metrics/collection/azureHttpMetricsInstrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import {
safeExecuteInTheMiddle,
} from "@opentelemetry/instrumentation";
import { getRequestInfo } from "@opentelemetry/instrumentation-http";
import { Histogram, MeterProvider, ValueType } from "@opentelemetry/api-metrics";
import { SpanKind, TracerProvider, Histogram, MeterProvider, ValueType } from "@opentelemetry/api";
import { SemanticAttributes } from "@opentelemetry/semantic-conventions";

import { APPLICATION_INSIGHTS_SDK_VERSION } from "../../declarations/constants";
import { HttpMetricsInstrumentationConfig, IHttpStandardMetric, MetricName } from "../types";
import { Logger } from "../../shared/logging";
import { SpanKind, TracerProvider } from "@opentelemetry/api";
import { SemanticAttributes } from "@opentelemetry/semantic-conventions";


export class AzureHttpMetricsInstrumentation extends InstrumentationBase<Http> {
private _nodeVersion: string;
Expand Down Expand Up @@ -47,7 +47,7 @@ export class AzureHttpMetricsInstrumentation extends InstrumentationBase<Http> {
this._updateMetricInstruments();
}

private _updateMetricInstruments() {
protected _updateMetricInstruments() {
this._httpServerDurationHistogram = this.meter.createHistogram(
MetricName.REQUEST_DURATION,
{ valueType: ValueType.DOUBLE }
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/collection/dependencyMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ObservableGauge,
ObservableResult,
ValueType,
} from "@opentelemetry/api-metrics";
} from "@opentelemetry/api";
import { AzureHttpMetricsInstrumentation } from "./azureHttpMetricsInstrumentation";
import { MetricName } from "../types";

Expand Down
2 changes: 1 addition & 1 deletion src/metrics/collection/exceptionMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Meter,
ObservableGauge,
ValueType,
} from "@opentelemetry/api-metrics";
} from "@opentelemetry/api";
import {
AggregatedMetricCounter,
IStandardMetricBaseDimensions,
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/collection/nativePerformanceMetrics.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Meter, ObservableGauge, ObservableResult, Histogram } from "@opentelemetry/api-metrics";
import { Meter, ObservableGauge, ObservableResult, Histogram } from "@opentelemetry/api";
import { GarbageCollectionType, NativeMetricsCounter } from "../types";
import { Logger } from "../../shared/logging";

Expand Down
2 changes: 1 addition & 1 deletion src/metrics/collection/processMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ObservableGauge,
ObservableResult,
ValueType,
} from "@opentelemetry/api-metrics";
} from "@opentelemetry/api";
import { MetricName } from "../types";

export class ProcessMetrics {
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/collection/requestMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ObservableGauge,
ObservableResult,
ValueType,
} from "@opentelemetry/api-metrics";
} from "@opentelemetry/api";
import { AzureHttpMetricsInstrumentation } from "./azureHttpMetricsInstrumentation";
import { MetricName } from "../types";

Expand Down
2 changes: 1 addition & 1 deletion src/metrics/collection/traceMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Meter,
ObservableGauge,
ValueType,
} from "@opentelemetry/api-metrics";
} from "@opentelemetry/api";
import {
AggregatedMetricCounter,
IMetricTraceDimensions,
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/handlers/customMetricsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
AzureMonitorExporterOptions,
AzureMonitorMetricExporter,
} from "@azure/monitor-opentelemetry-exporter";
import { Meter } from "@opentelemetry/api-metrics";
import { Meter } from "@opentelemetry/api";
import {
MeterProvider,
MeterProviderOptions,
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/handlers/heartBeatHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ObservableCallback,
ObservableGauge,
ObservableResult,
} from "@opentelemetry/api-metrics";
} from "@opentelemetry/api";
import {
MeterProvider,
PeriodicExportingMetricReader,
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/handlers/performanceCounterMetricsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
AzureMonitorExporterOptions,
AzureMonitorMetricExporter,
} from "@azure/monitor-opentelemetry-exporter";
import { Meter } from "@opentelemetry/api-metrics";
import { Meter } from "@opentelemetry/api";
import {
DropAggregation,
MeterProvider,
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/handlers/standardMetricsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
AzureMonitorExporterOptions,
AzureMonitorMetricExporter,
} from "@azure/monitor-opentelemetry-exporter";
import { Meter } from "@opentelemetry/api-metrics";
import { Meter } from "@opentelemetry/api";
import {
DropAggregation,
MeterProvider,
Expand Down
5 changes: 2 additions & 3 deletions src/metrics/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

import { IncomingMessage, RequestOptions } from "http";

import { SpanKind } from "@opentelemetry/api";
import { MetricAttributes, ValueType } from "@opentelemetry/api-metrics";
import { Attributes, SpanKind } from "@opentelemetry/api";
import { InstrumentationConfig } from "@opentelemetry/instrumentation";

export enum MetricName {
Expand Down Expand Up @@ -136,7 +135,7 @@ export interface IHttpStandardMetric {
startTime: number;
isProcessed: boolean;
spanKind: SpanKind;
attributes: MetricAttributes;
attributes: Attributes;
}

// Names expected in Breeze side for dimensions
Expand Down
7 changes: 0 additions & 7 deletions src/shared/configuration/applicationInsightsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export class ApplicationInsightsConfig implements IConfig {
public enableAutoCollectPerformance: boolean;
public enableAutoCollectStandardMetrics: boolean;
public enableAutoCollectHeartbeat: boolean;
public enableAutoCollectAzureFunctions: boolean;
public extendedMetrics: { [type: string]: boolean };
public instrumentations: InstrumentationsConfig;
public logInstrumentations: LogInstrumentationsConfig;
Expand Down Expand Up @@ -91,8 +90,6 @@ export class ApplicationInsightsConfig implements IConfig {
this.enableAutoCollectStandardMetrics !== undefined
? this.enableAutoCollectStandardMetrics
: true;
this.enableAutoCollectAzureFunctions =
this.enableAutoCollectAzureFunctions !== undefined ? this.enableAutoCollectAzureFunctions : true;
this.samplingRate = this.samplingRate !== undefined ? this.samplingRate : 1;
this.instrumentations = {
http: { enabled: true },
Expand Down Expand Up @@ -137,10 +134,6 @@ export class ApplicationInsightsConfig implements IConfig {
jsonConfig.enableAutoCollectStandardMetrics !== undefined
? jsonConfig.enableAutoCollectStandardMetrics
: this.enableAutoCollectStandardMetrics;
this.enableAutoCollectAzureFunctions =
jsonConfig.enableAutoCollectAzureFunctions !== undefined
? jsonConfig.enableAutoCollectAzureFunctions
: this.enableAutoCollectAzureFunctions;
this.samplingRate =
jsonConfig.samplingRate !== undefined ? jsonConfig.samplingRate : this.samplingRate;
this.storageDirectory =
Expand Down
2 changes: 0 additions & 2 deletions src/shared/configuration/jsonConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export class JsonConfig implements IConfig {
public enableAutoCollectPerformance: boolean;
public enableAutoCollectStandardMetrics: boolean;
public enableAutoCollectHeartbeat: boolean;
public enableAutoCollectAzureFunctions: boolean;
public disableOfflineStorage: boolean;
public storageDirectory: string;
public instrumentations: InstrumentationsConfig;
Expand Down Expand Up @@ -54,7 +53,6 @@ export class JsonConfig implements IConfig {
this.enableAutoCollectPerformance = jsonConfig.enableAutoCollectPerformance;
this.enableAutoCollectStandardMetrics = jsonConfig.enableAutoCollectStandardMetrics;
this.enableAutoCollectHeartbeat = jsonConfig.enableAutoCollectHeartbeat;
this.enableAutoCollectAzureFunctions = jsonConfig.enableAutoCollectAzureFunctions;
this.disableOfflineStorage = jsonConfig.disableOfflineStorage;
this.storageDirectory = jsonConfig.storageDirectory;
this.instrumentations = jsonConfig.instrumentations;
Expand Down
4 changes: 0 additions & 4 deletions src/shared/configuration/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ export interface IConfig {
* if true HeartBeat metric data will be collected every 15 minutes and sent to Application Insights
*/
enableAutoCollectHeartbeat: boolean;
/**
* Enable automatic incoming request tracking when running in Azure Functions
*/
enableAutoCollectAzureFunctions: boolean;
/**
* OpenTelemetry Instrumentations configuration included as part of Application Insights (azureSdk, http, mongoDb, mySql, postgreSql, redis, redis4)
*/
Expand Down
Loading