-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade to OpenTelemetry 1.18.1 / 0.45.1 (#852)
* update dependencies * disable automatic log sending for bunyan * reorder log tests * move log tests to separate files * increase job count for tests
- Loading branch information
Showing
10 changed files
with
953 additions
and
896 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright Splunk Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { TestLogStream, assertInjection } from './utils'; | ||
import { startTracing, stopTracing } from '../src/tracing'; | ||
import type * as bunyan from 'bunyan'; | ||
|
||
describe('log injection', () => { | ||
let logStream: TestLogStream; | ||
|
||
beforeEach(() => { | ||
logStream = new TestLogStream(); | ||
}); | ||
|
||
describe('injecting version and environment', () => { | ||
before(() => { | ||
process.env.OTEL_RESOURCE_ATTRIBUTES = | ||
'service.version=1,deployment.environment=test'; | ||
}); | ||
|
||
after(() => { | ||
delete process.env.OTEL_RESOURCE_ATTRIBUTES; | ||
}); | ||
|
||
it('injects service version and service environment if available', () => { | ||
startTracing({ serviceName: 'test-service' }); | ||
|
||
const logger: bunyan = require('bunyan').createLogger({ | ||
name: 'test', | ||
stream: logStream.stream, | ||
}); | ||
|
||
assertInjection(logStream, logger, [ | ||
['service.name', 'test-service'], | ||
['service.version', '1'], | ||
['service.environment', 'test'], | ||
]); | ||
|
||
stopTracing(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright Splunk Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import type * as pino from 'pino'; | ||
import { startTracing, stopTracing } from '../src/tracing'; | ||
import { TestLogStream, assertInjection } from './utils'; | ||
import { defaultLogHook } from '../src/instrumentations/logging'; | ||
import { PinoInstrumentation } from '@opentelemetry/instrumentation-pino'; | ||
|
||
describe('pino with with custom hooks', () => { | ||
let logStream: TestLogStream; | ||
|
||
beforeEach(() => { | ||
logStream = new TestLogStream(); | ||
}); | ||
afterEach(() => { | ||
stopTracing(); | ||
}); | ||
|
||
it('is possible to opt out from injecting resource attributes', () => { | ||
const MY_VALUE = 'myValue'; | ||
const MY_ATTRIBUTE = 'myAttribute'; | ||
startTracing({ | ||
serviceName: 'test-service', | ||
instrumentations: [ | ||
new PinoInstrumentation({ | ||
logHook: (span, logRecord) => { | ||
logRecord[MY_ATTRIBUTE] = MY_VALUE; | ||
}, | ||
}), | ||
], | ||
}); | ||
|
||
const logger: pino.Logger = require('pino')(logStream.stream); | ||
|
||
assertInjection(logStream, logger, [ | ||
['service.name', undefined], | ||
[MY_ATTRIBUTE, MY_VALUE], | ||
]); | ||
}); | ||
|
||
it('is easy enough do do both', () => { | ||
const MY_VALUE = 'myValueBoth'; | ||
const MY_ATTRIBUTE = 'myAttributeBoth'; | ||
startTracing({ | ||
serviceName: 'test-service', | ||
instrumentations: [ | ||
new PinoInstrumentation({ | ||
logHook: (span, logRecord) => { | ||
defaultLogHook(span, logRecord); | ||
logRecord[MY_ATTRIBUTE] = MY_VALUE; | ||
}, | ||
}), | ||
], | ||
}); | ||
|
||
const logger: pino.Logger = require('pino')(logStream.stream); | ||
|
||
assertInjection(logStream, logger, [ | ||
['service.name', 'test-service'], | ||
[MY_ATTRIBUTE, MY_VALUE], | ||
]); | ||
}); | ||
}); |
Oops, something went wrong.