Skip to content

Commit

Permalink
fix: review 1
Browse files Browse the repository at this point in the history
Signed-off-by: GALLLASMILAN <gallas.milan@gmail.com>
  • Loading branch information
GALLLASMILAN committed Dec 5, 2024
1 parent 9cb14c6 commit f1485c7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 113 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ yarn dev

### 🪑 Setup with OpenTelemetry

See the [Using Bee Observe OTLP Backend with OpenTelemetry](./docs/using-with-opentelemetry.md) section for instructions on how to use the Observe backend with the OpenTelemetry stack.
The Observe service can be used only with the [bee-agent-framework](https://github.com/i-am-bee/bee-agent-framework).
See [OpenTelemetry Instrumentation in Bee-Agent-Framework](https://github.com/i-am-bee/bee-agent-framework/blob/main/docs/instrumentation.md) for instructions on how to enable the instrumentation there.

For more info on setting up observe service in the [OpenTelemetry collector](https://opentelemetry.io/docs/collector/) read the [Configuration](https://opentelemetry.io/docs/collector/configuration/#exporters) page.

### 🧪 Run tests

Expand Down Expand Up @@ -165,4 +168,3 @@ Read all related document pages carefully to understand the Observer API archite
- [Overview](./docs/overview.md)
- [API](./docs/api.md)
- [Data persistence](./docs/data-persistence.md)
- [Using Bee Observe OTLP Backend with OpenTelemetry](./docs/using-with-opentelemetry.md)
106 changes: 0 additions & 106 deletions docs/using-with-opentelemetry.md

This file was deleted.

13 changes: 9 additions & 4 deletions src/trace/trace.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { Span } from '../span/span.document.js';
import { ExportTraceServiceRequest__Output } from '../types/generated/opentelemetry/proto/collector/trace/v1/ExportTraceServiceRequest.js';
import { findMainSpan } from '../span/utilt.js';
import { getServiceLogger } from '../utils/logger-factories.js';
import { constants } from '../utils/constants.js';

import { TraceDto, TraceGetOneQuery, TraceGetQuery } from './trace.dto.js';
import { assemblyTrace } from './utils/assembly-trace.js';
Expand Down Expand Up @@ -81,9 +82,13 @@ export async function getTrace({

export async function createTrace(traceBody: ExportTraceServiceRequest__Output): Promise<TraceDto> {
const spans = [...traceBody.resourceSpans].flatMap((resourceSpan) => {
return resourceSpan.scopeSpans.flatMap((scopeSpan) => {
return scopeSpan.spans.map((span) => new Span(span));
});
return resourceSpan.scopeSpans
.filter(
(scopeSpan) => scopeSpan.scope?.name === constants.OPENTELEMETRY.INSTRUMENTATION_SCOPE
)
.flatMap((scopeSpan) => {
return scopeSpan.spans.map((span) => new Span(span));
});
});

const mainSpan = findMainSpan(spans);
Expand Down Expand Up @@ -132,7 +137,7 @@ export function traceProtobufBufferParser(
payload: string | Buffer,
done: ContentTypeParserDoneFunction
) {
if (req.url !== '/v1/traces') {
if (req.url !== '/v1/traces' || req.method.toLowerCase() !== 'post') {
return done(
new ErrorWithProps(
'Invalid url for protobuf format',
Expand Down
5 changes: 4 additions & 1 deletion src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,8 @@ export const constants = Object.freeze({
TRACE_DELETE_IN_BATCHES_BATCH_SIZE: parseInt(
process.env.MLFLOW_TRACE_DELETE_IN_BATCHES_BATCH_SIZE || '100'
)
})
}),
OPENTELEMETRY: {
INSTRUMENTATION_SCOPE: 'bee-agent-framework'
}
});

0 comments on commit f1485c7

Please sign in to comment.