Skip to content

Commit

Permalink
Merge pull request #3 from logzio/dev
Browse files Browse the repository at this point in the history
1.0.2
  • Loading branch information
yotamloe committed Nov 20, 2022
2 parents 87ccc06 + 393e675 commit 51106e8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN apt-get -y install curl
COPY ./config.py config.py
COPY ./entrypoint.sh entrypoint.sh
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
RUN curl -L https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.48.0/otelcol-contrib_0.48.0_linux_amd64.tar.gz -o otelcol-contrib.tar.gz
RUN curl -L https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.64.0/otelcol-contrib_0.64.0_linux_amd64.tar.gz -o otelcol-contrib.tar.gz
RUN tar -xf otelcol-contrib.tar.gz otelcol-contrib
RUN mv otelcol-contrib otelcontribcol
EXPOSE 4317 55680 55679 8888 6060 7276 9411 9943 1234 6831 6832 14250 14268 4317 4318 8888
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ logzio/otel-collector-spm
```

### Environment variables configuration:
* `LOG_LEVEL` (Optional) : Defines the opentelemetry collector log level. One of either `info` or `debug`. Default: `info`

* `LATENCY_HISTOGRAM_BUCKETS` (Optional): Comma separated list of durations defining the latency histogram buckets. Default: `2ms, 8ms, 50ms, 100ms, 200ms, 500ms, 1s, 5s, 10s`

* `SPAN_METRICS_DIMENSIONS` (Optional) : Each metric will have at least the following dimensions because they are common across all spans: `Service name`,`Operation`,`Span kind`,`Status code`. The input is comma separated list of dimensions to add together with the default dimensions (example: `region,http.url`). Each additional dimension is defined with a name which is looked up in the span's collection of attributes or resource attributes. If the named attribute is missing in the span, this dimension will be omitted from the metric.
Expand Down Expand Up @@ -78,6 +80,11 @@ logzio/otel-collector-spm
- 9411

## Changelog
**1.0.2**
- Add `LOG_LEVEL` flag
- Otel version `0.48.0` -> `0.64.0`
**1.0.1**
- Otel version `0.45.0` -> `0.48.0`
**1.0.0**
- SPM container initial release

21 changes: 21 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,26 @@ def is_valid_aggregation_temporality(aggregation_temporality):
return True


def is_valid_log_level(log_level):
if type(log_level) is not str:
raise TypeError("LOG_LEVEL should be a string")
valid_log_levels = ["info", "debug"]
if log_level != "":
if log_level not in valid_log_levels:
raise ValueError(
"invalid log level: {}. allowed values are {}".format(log_level,
valid_log_levels))
return True


def inputValidator():
is_valid_logzio_region_code(os.getenv("LOGZIO_REGION"))
is_valid_logzio_token(os.getenv("LOGZIO_TRACES_TOKEN"))
is_valid_logzio_token(os.getenv("LOGZIO_METRICS_TOKEN"))
if os.getenv("AGGREGATION_TEMPORALITY") is not None:
is_valid_aggregation_temporality(os.getenv("AGGREGATION_TEMPORALITY"))
if os.getenv("LOG_LEVEL") is not None:
is_valid_log_level(os.getenv("LOG_LEVEL"))


if __name__ == '__main__':
Expand Down Expand Up @@ -108,5 +122,12 @@ def inputValidator():
logger.info('No span metrics aggregation_temporality found in environment variables, setting to default: '
'AGGREGATION_TEMPORALITY_CUMULATIVE')

if os.getenv("LOG_LEVEL") is not None:
logger.info('Updating opentelemetry collector log level')
logLevel = os.getenv("LOG_LEVEL")
config["service"]["telemetry"]["logs"]["level"] = logLevel
else:
logger.info('No log level found in environment variables, setting to default: info')

with open("/etc/otel/config.yaml", "w") as f:
yaml.dump(config, f)
2 changes: 1 addition & 1 deletion otel-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ service:
exporters: [prometheusremotewrite]
telemetry:
logs:
level: "debug"
level: "info"

0 comments on commit 51106e8

Please sign in to comment.