Skip to content

Support explicit timestamps for metric observations - #4411

Draft
plengauer with Copilot wants to merge 2 commits into
mainfrom
copilot/support-optional-timestamp-for-metrics
Draft

plengauer with Copilot wants to merge 2 commits into
mainfrom
copilot/support-optional-timestamp-for-metrics

Conversation

Copilot AI commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Metric recordings lacked the optional explicit timestamps available for spans. Add @timestamp support while preserving current-time defaults for existing callers.

  • API: Accept timestamps on observation creation and counter recording; a timestamp on recording takes precedence.
  • SDK: Propagate timestamps to synchronous and observable metric measurements.
observation_handle="$(otel_observation_create 5 @2026-10-12T10:52:27Z)"
otel_counter_observe "$counter_handle" "$observation_handle"

# Override the observation timestamp when recording
otel_counter_observe "$counter_handle" "$observation_handle" @2026-10-12T10:52:30Z

@plengauer

Copy link
Copy Markdown
Owner

Hello, thanks for contributing for the first time!

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

❌MegaLinter analysis: Error

Descriptor Linter Files Fixed Errors Max errors Warnings Elapsed time
❌ BASH shellcheck 2 1 40 2.3s
⚠️ BASH shfmt 2 1 0 0.03s
❌ COPYPASTE jscpd yes 103 no 4.33s
✅ MARKDOWN markdownlint 1 0 0 0.56s
⚠️ MARKDOWN markdown-table-formatter 1 1 0 0.22s
❌ PYTHON bandit 1 1 4 1.48s
⚠️ PYTHON black 1 1 0 2.97s
❌ PYTHON flake8 1 117 0 1.05s
⚠️ PYTHON isort 1 12 0 0.31s
✅ PYTHON mypy 1 0 0 10.52s
❌ PYTHON pylint 1 63 0 11.13s
❌ PYTHON pyright 1 60 0 3.67s
❌ PYTHON ruff 1 3 0 0.15s
✅ REPOSITORY betterleaks yes no no 12.2s
❌ REPOSITORY checkov yes 9 no 27.12s
✅ REPOSITORY dustilock yes no no 0.8s
✅ REPOSITORY git_diff yes no no 0.21s
❌ REPOSITORY grype yes 2 1 109.52s
✅ REPOSITORY kingfisher yes no no 7.28s
❌ REPOSITORY osv-scanner yes 1 5 8.47s
✅ REPOSITORY secretlint yes no no 3.34s
✅ REPOSITORY syft yes no no 6.67s
❌ REPOSITORY trivy yes 12 8 18.45s
✅ REPOSITORY trivy-sbom yes no no 1.04s
✅ REPOSITORY trufflehog yes no no 13.39s
❌ SPELL cspell 5 31 0 5.38s
✅ SPELL lychee 1 0 0 1.2s

Detailed Issues

❌ PYTHON / bandit - 1 error
note: Try, Except, Pass detected.
   ┌─ src/usr/share/opentelemetry_shell/sdk.py:68:1
   │
68 │     except Exception:
   │ ^^^^^^^^^^^^^^^^^^^^^

note: Try, Except, Pass detected.
    ┌─ src/usr/share/opentelemetry_shell/sdk.py:629:1
    │
629 │         except Exception:
    │ ^^^^^^^^^^^^^^^^^^^^^^^^^

note: Try, Except, Pass detected.
    ┌─ src/usr/share/opentelemetry_shell/sdk.py:633:1
    │
633 │         except Exception:
    │ ^^^^^^^^^^^^^^^^^^^^^^^^^

note: Try, Except, Pass detected.
    ┌─ src/usr/share/opentelemetry_shell/sdk.py:644:1
    │
644 │     except Exception:
    │ ^^^^^^^^^^^^^^^^^^^^^
❌ REPOSITORY / checkov - 9 errors
st a dummy to trigger renovate on new versions
  │ ╰───────────────────────────────────────────────────────────────^
  │  
  = Ensure that a user for the container has been created
  = Ensure that a user for the container has been created

error: Ensure the base image uses a non latest version tag
  ┌─ tests/Dockerfile:5:1
  │
5 │ FROM $image
  │ ^^^^^^^^^^^
  │
  = Ensure the base image uses a non latest version tag
  = Ensure the base image uses a non latest version tag

error: Ensure that a user for the container has been created
   ┌─ tests/Dockerfile:1:1
   │  
 1 │ ╭ ARG image
 2 │ │ ARG update
 3 │ │ ARG shell
 4 │ │ 
   · │
14 │ │   if type apt-get; then
15 │ │     apt-get update
   │ ╰──────────────────^
   │  
   = Ensure that a user for the container has been created
   = Ensure that a user for the container has been created

error: Ensure that sudo isn't used
   ┌─ tests/Dockerfile:11:1
   │
11 │ RUN <<EOF
   │ ^^^^^^^^^
   │
   = Ensure that sudo isn't used
   = Ensure that sudo isn't used

error: Ensure that packages with untrusted or missing signatures are not used by apk via the '--allow-untrusted' option
   ┌─ actions/instrument/workflow/Dockerfile:10:1
   │
10 │ RUN cd /root && apk add --allow-untrusted bash jq curl parallel unzip findutils coreutils /root/*.apk && rm -rf /root/*.apk /usr/share/opentelemetry_shell/agent.instrumentation.*/*.xz /usr/share/opentelemetry_shell/agent.instrumentation.*/*.zst /usr/share/opentelemetry_shell/agent.instrumentation.*/*/
   │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   │
   = Ensure that packages with untrusted or missing signatures are not used by apk via the '--allow-untrusted' option
   = Ensure that packages with untrusted or missing signatures are not used by apk via the '--allow-untrusted' option

error: Ensure that packages with untrusted or missing signatures are not used by apk via the '--allow-untrusted' option
   ┌─ tests/Dockerfile:11:1
   │
11 │ RUN <<EOF
   │ ^^^^^^^^^
   │
   = Ensure that packages with untrusted or missing signatures are not used by apk via the '--allow-untrusted' option
   = Ensure that packages with untrusted or missing signatures are not used by apk via the '--allow-untrusted' option

error: 9 errors emitted

(Truncated to last 2500 characters out of 4378)
❌ SPELL / cspell - 31 errors
Suggestions: [dent, dint, doit, dolt, dona]
src/usr/share/opentelemetry_shell/sdk.py:78:35     - Unknown word (waagent)    -- path.exists('/var/lib/waagent/'):
	 Suggestions: [wagent, WAgent, agent, argent, haagen]
src/usr/share/opentelemetry_shell/sdk.py:82:28     - Unknown word (resourcedetector) -- from opentelemetry.resourcedetector.gcp_resource_detector
	 Suggestions: []
src/usr/share/opentelemetry_shell/sdk.py:117:28    - Unknown word (resourcedetector) -- from opentelemetry.resourcedetector.gcp_resource_detector
	 Suggestions: []
src/usr/share/opentelemetry_shell/sdk.py:294:28    - Unknown word (resourcedetector) -- from opentelemetry_resourcedetector_docker import DockerResourceD
	 Suggestions: []
src/usr/share/opentelemetry_shell/sdk.py:295:28    - Unknown word (resourcedetector) -- from opentelemetry_resourcedetector_kubernetes import KubernetesR
	 Suggestions: []
src/usr/share/opentelemetry_shell/sdk.py:371:9     - Unknown word (keyvaluepair)     -- keyvaluepair = tokens[2]
	 Suggestions: []
src/usr/share/opentelemetry_shell/sdk.py:372:18    - Unknown word (keyvaluepair)     -- tokens = keyvaluepair.split('=', 1)
	 Suggestions: []
src/usr/share/opentelemetry_shell/sdk.py:413:9     - Unknown word (keyvaluepair)     -- keyvaluepair = tokens[2]
	 Suggestions: []
src/usr/share/opentelemetry_shell/sdk.py:414:18    - Unknown word (keyvaluepair)     -- tokens = keyvaluepair.split('=', 1)
	 Suggestions: []
src/usr/share/opentelemetry_shell/sdk.py:448:9     - Unknown word (keyvaluepair)     -- keyvaluepair = tokens[2]
	 Suggestions: []
CSpell: Files checked: 5, Issues found: 31 in 3 files.


You can skip this misspellings by defining the following .cspell.json file at the root of your repository
Of course, please correct real typos before :)

{
    "version": "0.2",
    "language": "en",
    "ignorePaths": [
        "**/node_modules/**",
        "**/vscode-extension/**",
        "**/.git/**",
        "**/.pnpm-lock.json",
        ".vscode",
        "package-lock.json",
        "megalinter-reports"
    ],
    "words": [
        "OLWCN",
        "SAMEORIGIN",
        "commandlines",
        "deamon",
        "doesnt",
        "dont",
        "keyvaluepair",
        "linefeeds",
        "mycommand",
        "numberkey",
        "paramters",
        "postrm",
        "preinst",
        "resourcedetector",
        "resuable",
        "specifc",
        "waagent"
    ]
}


You can also copy-paste megalinter-reports/.cspell.json at the root of your repository

(Truncated to last 2500 characters out of 5852)
❌ PYTHON / flake8 - 117 errors
espace after '['
src/usr/share/opentelemetry_shell/sdk.py:491:89: E501 line too long (172 > 88 characters)
src/usr/share/opentelemetry_shell/sdk.py:491:134: E202 whitespace before ']'
src/usr/share/opentelemetry_shell/sdk.py:495:83: E201 whitespace after '['
src/usr/share/opentelemetry_shell/sdk.py:495:89: E501 line too long (180 > 88 characters)
src/usr/share/opentelemetry_shell/sdk.py:495:142: E202 whitespace before ']'
src/usr/share/opentelemetry_shell/sdk.py:499:73: E201 whitespace after '['
src/usr/share/opentelemetry_shell/sdk.py:499:89: E501 line too long (170 > 88 characters)
src/usr/share/opentelemetry_shell/sdk.py:499:132: E202 whitespace before ']'
src/usr/share/opentelemetry_shell/sdk.py:511:89: E501 line too long (118 > 88 characters)
src/usr/share/opentelemetry_shell/sdk.py:517:89: E501 line too long (97 > 88 characters)
src/usr/share/opentelemetry_shell/sdk.py:522:89: E501 line too long (94 > 88 characters)
src/usr/share/opentelemetry_shell/sdk.py:527:89: E501 line too long (94 > 88 characters)
src/usr/share/opentelemetry_shell/sdk.py:533:89: E501 line too long (165 > 88 characters)
src/usr/share/opentelemetry_shell/sdk.py:540:89: E501 line too long (94 > 88 characters)
src/usr/share/opentelemetry_shell/sdk.py:543:41: E201 whitespace after '{'
src/usr/share/opentelemetry_shell/sdk.py:543:89: E501 line too long (123 > 88 characters)
src/usr/share/opentelemetry_shell/sdk.py:543:122: E202 whitespace before '}'
src/usr/share/opentelemetry_shell/sdk.py:560:89: E501 line too long (94 > 88 characters)
src/usr/share/opentelemetry_shell/sdk.py:580:1: E302 expected 2 blank lines, found 1
src/usr/share/opentelemetry_shell/sdk.py:583:89: E501 line too long (129 > 88 characters)
src/usr/share/opentelemetry_shell/sdk.py:585:1: E302 expected 2 blank lines, found 1
src/usr/share/opentelemetry_shell/sdk.py:595:89: E501 line too long (170 > 88 characters)
src/usr/share/opentelemetry_shell/sdk.py:598:89: E501 line too long (92 > 88 characters)
src/usr/share/opentelemetry_shell/sdk.py:602:1: E302 expected 2 blank lines, found 1
src/usr/share/opentelemetry_shell/sdk.py:620:17: E201 whitespace after '['
src/usr/share/opentelemetry_shell/sdk.py:620:23: E202 whitespace before ']'
src/usr/share/opentelemetry_shell/sdk.py:620:25: E703 statement ends with a semicolon
src/usr/share/opentelemetry_shell/sdk.py:639:1: E302 expected 2 blank lines, found 1
src/usr/share/opentelemetry_shell/sdk.py:648:1: E305 expected 2 blank lines after class or function definition, found 1

(Truncated to last 2500 characters out of 10406)
❌ REPOSITORY / grype - 2 errors
error: A high vulnerability in npm package: brace-expansion, version 2.1.4 was found at: /actions/instrument/job/package-lock.json

error: A high vulnerability in npm package: brace-expansion, version 2.1.4 was found at: /actions/instrument/job/package-lock.json

warning: A medium vulnerability in npm package: brace-expansion, version 2.1.4 was found at: /actions/instrument/job/package-lock.json

warning: 1 warnings emitted
error: 2 errors emitted
❌ COPYPASTE / jscpd - 103 errors
quals "$(\cat "$expected" | \xxd -p)" "$(\cat "$actual" | \xxd -p)" # get some flaky fails on this one when random internet is scanning the port
    │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────^
    │  
    ┌─ tests/auto/test_auto_netcat.sh:110:33
    │  
110 │   \cat /dev/urandom | \tr -d '\n' | \head -c $((1024 * 1)) >"$expected" || \true
    │ ╭─────────────────────────────────'
111 │ │ netcat -l "$port" >"$actual" &
112 │ │ pid="$!"
113 │ │ \sleep 3
114 │ │ \cat "$expected" | netcat -w 10 127.0.0.1 "$port"
115 │ │ \wait "$pid" || \true
116 │ │ [ -z "$(\cat "$actual" | \xxd -p)" ] || assert_equals "$(\cat "$expected" | \xxd -p)" "$(\cat "$actual" | \xxd -p)" # get some flaky fails on this one when random internet is scanning the port
    │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────' Duplicated at tests/auto/test_auto_netcat.sh:110

error: Duplicated code block (92 tokens), duplicated at [tests/auto/test_auto_wget.sh:40](0)
   ┌─ tests/auto/test_auto_wget.sh:21:19
   │  
21 │   assert_equals "/" "$(\echo "$span" | jq -r '.attributes."url.path"')"
   │ ╭───────────────────^
22 │ │ assert_equals null "$(\echo "$span" | jq -r '.attributes."url.query"')"
23 │ │ assert_equals "wget" "$(\echo "$span" | jq -r '.attributes."user_agent.original"')"
24 │ │ assert_equals "200" "$(\echo "$span" | jq -r '.attributes."http.response.status_code"')"
   · │
28 │ │ 
29 │ │ $TEST_SHELL auto/wget.sh https://www.google.de/index.html https://www.google.de/index || true
   │ ╰────────────────────────────────────^
   │  
   ┌─ tests/auto/test_auto_wget.sh:40:29
   │  
40 │   assert_equals "/index.html" "$(\echo "$span" | jq -r '.attributes."url.path"')"
   │ ╭─────────────────────────────'
41 │ │ assert_equals null "$(\echo "$span" | jq -r '.attributes."url.query"')"
42 │ │ assert_equals "wget" "$(\echo "$span" | jq -r '.attributes."user_agent.original"')"
43 │ │ assert_equals "200" "$(\echo "$span" | jq -r '.attributes."http.response.status_code"')"
   · │
48 │ │ span="$(resolve_span '.attributes."url.path" == "/index"')"
49 │ │ assert_equals "GET" "$(\echo "$span" | jq -r '.name')"
   │ ╰───────────────────' Duplicated at tests/auto/test_auto_wget.sh:40

error: 103 errors emitted

(Truncated to last 2500 characters out of 144507)
❌ REPOSITORY / osv-scanner - 1 error
imatch` / `glob` as a user-supplied glob pattern, can be crashed. In Node a `RangeError` the application does not catch terminates the process, so a server globbing user input is exposed to remote unauthenticated denial of service.
   
   Availability only. No code execution, no data exposure.
   
   ### Affected versions
   
   Verified affected on 1.1.18, 2.1.4, 3.0.6 and 5.0.9, at near-identical depths on every line (single set: 3,125 on all four; comma members: 3,907-4,102). Not a regression from any recent fix - the gap predates them.
   
   ### Patch
   
   A `maxDepth` bound (default `EXPANSION_MAX_DEPTH`) is threaded through `expand_()`. Past the cap a group is treated as non-expanding and returned literally, which is how the parser already handles a group that cannot expand. This matches the existing `max` / `maxLength` caps, which truncate rather than throw, so `expand()` continues never to throw on any input.
   
   The default sits far above any realistic nesting depth and well below the crash threshold.

warning: Package 'idna@3.9.0' is vulnerable to 'CVE-2026-45409' (also known as 'PYSEC-2026-215', 'GHSA-65pc-fj4g-8rjx').
 = CVE-2026-45409: Internationalized Domain Names in Applications (IDNA): Specially crafted inputs to idna.encode() can bypass CVE-2024-3651 fix
 = This is the same issue as CVE-2024-3651, however the original remediation in 2024 was not a complete fix. Payloads such as `"\u0660" * N` or `"\u30fb" * N + "\u6f22"` utilize the `valid_contexto` function prior to length rejection, and for high values of `N` will take a long time to process.
   
   ### Impact
   A specially crafted argument to the `idna.encode()` function could consume significant resources. This may lead to a denial-of-service.
   
   ### Patches
   Starting in version 3.14, the function rejects long inputs as soon as practicable prior to any further processing to minimize resource consumption. In version 3.15, this approach was extended to lesser used alternate functions (i.e. per-label conversions and codec support).
   
   ### Workarounds
   Domain names cannot exceed 253 characters in length, if this length limit is enforced prior to passing the domain to the `idna.encode()` function it should no longer consume significant resources. This is triggered by arbitrarily large inputs that would not occur in normal usage, but may be passed to the library assuming there is no preliminary input validation by the higher-level application.

warning: 5 warnings emitted

(Truncated to last 2500 characters out of 14249)
❌ PYTHON / pylint - 63 errors
etry.trace.propagation.tracecontext' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:333:8: E0401: Unable to import 'opentelemetry.sdk.trace' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:341:8: E0401: Unable to import 'opentelemetry.trace' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:342:8: E0401: Unable to import 'opentelemetry.sdk.trace' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:343:8: E0401: Unable to import 'opentelemetry.trace.propagation.tracecontext' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:356:8: E0401: Unable to import 'opentelemetry.sdk.trace' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:363:8: E0401: Unable to import 'opentelemetry.sdk.trace' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:367:8: E0401: Unable to import 'opentelemetry.sdk.trace' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:380:8: E0401: Unable to import 'opentelemetry.sdk.trace' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:381:8: E0401: Unable to import 'opentelemetry.trace' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:382:8: E0401: Unable to import 'opentelemetry.trace.propagation.tracecontext' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:421:8: E0401: Unable to import 'opentelemetry.sdk.trace' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:429:8: E0401: Unable to import 'opentelemetry.sdk.trace' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:430:8: E0401: Unable to import 'opentelemetry.trace' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:431:8: E0401: Unable to import 'opentelemetry.trace.propagation.tracecontext' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:456:8: E0401: Unable to import 'opentelemetry.sdk.trace' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:464:8: E0401: Unable to import 'opentelemetry.metrics' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:465:8: E0401: Unable to import 'opentelemetry.sdk.metrics' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:558:8: E0401: Unable to import 'opentelemetry._logs' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:559:8: E0401: Unable to import 'opentelemetry.sdk._logs._internal' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:560:8: E0401: Unable to import 'opentelemetry.trace.propagation.tracecontext' (import-error)
src/usr/share/opentelemetry_shell/sdk.py:581:4: E0401: Unable to import 'opentelemetry.metrics' (import-error)

(Truncated to last 2500 characters out of 7701)
❌ PYTHON / pyright - 60 errors
ace.propagation.tracecontext" could not be resolved (reportMissingImports)
  src/usr/share/opentelemetry_shell/sdk.py:356:14 - error: Import "opentelemetry.sdk.trace" could not be resolved (reportMissingImports)
  src/usr/share/opentelemetry_shell/sdk.py:363:14 - error: Import "opentelemetry.sdk.trace" could not be resolved (reportMissingImports)
  src/usr/share/opentelemetry_shell/sdk.py:367:14 - error: Import "opentelemetry.sdk.trace" could not be resolved (reportMissingImports)
  src/usr/share/opentelemetry_shell/sdk.py:380:14 - error: Import "opentelemetry.sdk.trace" could not be resolved (reportMissingImports)
  src/usr/share/opentelemetry_shell/sdk.py:381:14 - error: Import "opentelemetry.trace" could not be resolved (reportMissingImports)
  src/usr/share/opentelemetry_shell/sdk.py:382:14 - error: Import "opentelemetry.trace.propagation.tracecontext" could not be resolved (reportMissingImports)
  src/usr/share/opentelemetry_shell/sdk.py:421:14 - error: Import "opentelemetry.sdk.trace" could not be resolved (reportMissingImports)
  src/usr/share/opentelemetry_shell/sdk.py:429:14 - error: Import "opentelemetry.sdk.trace" could not be resolved (reportMissingImports)
  src/usr/share/opentelemetry_shell/sdk.py:430:14 - error: Import "opentelemetry.trace" could not be resolved (reportMissingImports)
  src/usr/share/opentelemetry_shell/sdk.py:431:14 - error: Import "opentelemetry.trace.propagation.tracecontext" could not be resolved (reportMissingImports)
  src/usr/share/opentelemetry_shell/sdk.py:456:14 - error: Import "opentelemetry.sdk.trace" could not be resolved (reportMissingImports)
  src/usr/share/opentelemetry_shell/sdk.py:464:14 - error: Import "opentelemetry.metrics" could not be resolved (reportMissingImports)
  src/usr/share/opentelemetry_shell/sdk.py:465:14 - error: Import "opentelemetry.sdk.metrics" could not be resolved (reportMissingImports)
  src/usr/share/opentelemetry_shell/sdk.py:558:14 - error: Import "opentelemetry._logs" could not be resolved (reportMissingImports)
  src/usr/share/opentelemetry_shell/sdk.py:559:14 - error: Import "opentelemetry.sdk._logs._internal" could not be resolved (reportMissingImports)
  src/usr/share/opentelemetry_shell/sdk.py:560:14 - error: Import "opentelemetry.trace.propagation.tracecontext" could not be resolved (reportMissingImports)
  src/usr/share/opentelemetry_shell/sdk.py:581:10 - error: Import "opentelemetry.metrics" could not be resolved (reportMissingImports)
60 errors, 0 warnings, 0 informations

(Truncated to last 2500 characters out of 8831)
❌ PYTHON / ruff - 3 errors
error: `opentelemetry.sdk.resources.ResourceDetector` imported but unused

error: Test for membership should be `not in`

error: Statement ends with an unnecessary semicolon

error: 3 errors emitted
❌ BASH / shellcheck - 1 error
74
    │
420 │     otel_span_attribute_typed "$span_handle" string shell.command.name=""${command_name##*/}""
    │                                                                          -
    │
    ┌─ src/usr/share/opentelemetry_shell/api.sh:420:93
    │
420 │     otel_span_attribute_typed "$span_handle" string shell.command.name=""${command_name##*/}""
    │                                                                                             -
    │
    = SC2086
    = For more information: https://www.shellcheck.net/wiki/SC2086

note: Note that A && B || C is not if-then-else. C may run when A is true.
    ┌─ src/usr/share/opentelemetry_shell/api.sh:425:70
    │
425 │     local executable_path="$(_otel_string_contains "$command_name" / && \echo "$command_name" || \which "$command_name")"
    │                                                                      ^^
    │
    = SC2015
    = For more information: https://www.shellcheck.net/wiki/SC2015

note: Double quote to prevent globbing and word splitting.
    ┌─ src/usr/share/opentelemetry_shell/api.sh:448:12
    │
448 │     set -- $attributes
    │            ^^^^^^^^^^^
    │
    ┌─ src/usr/share/opentelemetry_shell/api.sh:448:12
    │
448 │     set -- $attributes
    │            -
    │
    ┌─ src/usr/share/opentelemetry_shell/api.sh:448:23
    │
448 │     set -- $attributes
    │                       -
    │
    = SC2086
    = For more information: https://www.shellcheck.net/wiki/SC2086

note: Note that A && B || C is not if-then-else. C may run when A is true.
    ┌─ src/usr/share/opentelemetry_shell/api.sh:488:45
    │
488 │   \alias "$command" 1>/dev/null 2>/dev/null && \eval "$(_otel_escape_args "${command#\\}" "$@")" || "${command#\\}" "$@"
    │                                             ^^
    │
    = SC2015
    = For more information: https://www.shellcheck.net/wiki/SC2015

note: Don't use variables in the printf format string. Use printf '..%s..' "$foo".
    ┌─ src/usr/share/opentelemetry_shell/api.sh:551:13
    │
551 │     \printf "$1" "${2//\'/\'\\\'\'}"
    │             ^^^^
    │
    = SC2059
    = For more information: https://www.shellcheck.net/wiki/SC2059

note: Don't use variables in the printf format string. Use printf '..%s..' "$foo".
    ┌─ src/usr/share/opentelemetry_shell/api.sh:556:13
    │
556 │     \printf "$1" "${escaped%X}"
    │             ^^^^
    │
    = SC2059
    = For more information: https://www.shellcheck.net/wiki/SC2059

warning: 2 warnings emitted

(Truncated to last 2500 characters out of 23116)
❌ REPOSITORY / trivy - 12 errors
et update ;     [ "$update" = TRUE ] && DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y || true ;     type "$shell" || DEBIAN_FRONTEND=noninteractive apt-get install -y "$shell" ;     DEBIAN_FRONTEND=noninteractive apt-get install -y $packages_mandatory debconf debconf-utils python3-venv ;     DEBIAN_FRONTEND=noninteractive apt-get install -y $packages_optional || true ;     DEBIAN_FRONTEND=noninteractive apt-get install -y ./opentelemetry-shell_*_"$(arch | sed s/x86_64/amd64/g | sed s/aarch64/arm64/g | sed 's/le$/el/g')".deb ;   elif type dnf; then ;     [ "$update" = TRUE ] && dnf -y upgrade --refresh ;     type "$shell" || dnf -y install "$shell" ;     dnf -y install --allowerasing $packages_mandatory ;     for package in $packages_optional; do dnf -y install --allowerasing $package || true; done ;     dnf -y install ./opentelemetry-shell-*."$(arch)".rpm ;   elif type yum; then ;     [ "$update" = TRUE ] && yum -y upgrade ;     type "$shell" || yum -y install "$shell" ;     yum -y install --allowerasing $packages_mandatory ;     for package in $packages_optional; do yum -y install --allowerasing $package || true; done ;     yum -y install ./opentelemetry-shell-*."$(arch)".rpm ;   elif type zypper; then ;     [ "$update" = TRUE ] && zypper --non-interactive update ;     type "$shell" || zypper --non-interactive install "$shell" ;     zypper --non-interactive install $packages_mandatory ;     for package in $packages_optional; do zypper --non-interactive install $package || true; done ;     zypper --non-interactive install --allow-unsigned-rpm ./opentelemetry-shell-*."$(arch)".rpm ;   elif type apk; then ;     [ "$update" = TRUE ] && apk upgrade ;     type "$shell" || apk add "$shell" ;     for package in $packages_mandatory; do apk add $package || true; done ;     for package in $packages_optional; do apk add $package || true; done ;     apk add --allow-untrusted ./*.apk ;   else ;     exit 1 ;   fi'
Link: [DS-0029](https://avd.aquasec.com/misconfig/ds-0029)
   ┌─ tests/Dockerfile:11:1
   │  
11 │ ╭ RUN <<EOF
12 │ │   packages_mandatory="jq psmisc wget curl time sudo bash"
13 │ │   packages_optional="parallel moreutils ncat wget2 nodejs npm python3 python3-pip gcc default-jdk-headless jdk"
14 │ │   if type apt-get; then
   · │
47 │ │   fi
48 │ │ EOF
   │ ╰^
   │  
   = 'apt-get' missing '--no-install-recommends'
   = 'apt-get' install should use '--no-install-recommends' to minimize image size.

warning: 2 warnings emitted
error: 10 errors emitted

(Truncated to last 2500 characters out of 19093)
⚠️ PYTHON / black - 1 error
.replace(tzinfo=timezone.utc)
+            .timestamp()
+            * int(1e9)
+        ) + int(fractional_seconds_part.ljust(9, "0")[:9])
+    elif "." in time_string:
+        seconds_part, fractional_seconds_part = time_string.split(".")
+        return int(seconds_part) * int(1e9) + int(
+            fractional_seconds_part.ljust(9, "0")[:9]
+        )
     else:
         return int(time_string)
 
+
 def convert_type(type, value, base=None):
-    if type == 'string':
+    if type == "string":
         return value
-    elif type == 'int':
+    elif type == "int":
         return int(value)
-    elif type == '+int':
+    elif type == "+int":
         if base:
-            return base + convert_type('int', value)
+            return base + convert_type("int", value)
         else:
-            return convert_type('int', value)
-    elif type == 'float':
+            return convert_type("int", value)
+    elif type == "float":
         return float(value)
-    elif type == '+float':
+    elif type == "+float":
         if base:
-            return base + convert_type('float', value)
+            return base + convert_type("float", value)
         else:
-            return convert_type('float', value)
-    elif type == 'string[1]':
-        return [ value ];
-    elif type == '+string[1]':
+            return convert_type("float", value)
+    elif type == "string[1]":
+        return [value]
+    elif type == "+string[1]":
         if base:
-            return list(base) + convert_type('string[1]', value)
+            return list(base) + convert_type("string[1]", value)
         else:
-            return convert_type('string[1]', value)
-    elif type == 'auto':
+            return convert_type("string[1]", value)
+    elif type == "auto":
         try:
             return int(value)
         except Exception:
             pass
         try:
             return float(value)
         except Exception:
             pass
         return value
     else:
-        raise Exception('Unknown type: ' + type)
+        raise Exception("Unknown type: " + type)
+
 
 def file_contains(haystack, needle):
     try:
-        with open(haystack, 'r') as file:
+        with open(haystack, "r") as file:
             if needle in file.read():
                 return True
     except Exception:
         pass
     return False
 
+
 if __name__ == "__main__":
     main()
would reformat src/usr/share/opentelemetry_shell/sdk.py

Oh no! 💥 💔 💥
1 file would be reformatted.

(Truncated to last 2500 characters out of 50129)
⚠️ PYTHON / isort - 12 errors
Kind
-        from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator
+        from opentelemetry.trace import SpanKind, get_tracer
+        from opentelemetry.trace.propagation.tracecontext import (
+            TraceContextTextMapPropagator,
+        )
         global next_span_id
         tokens = arguments.split(' ', 5)
         response_path = tokens[0]
@@ -338,9 +376,11 @@
         span.end(end_time=parse_time(end_time))
         del spans[span_id]
     elif command == 'SPAN_HANDLE':
+        from opentelemetry.sdk.trace import Span
         from opentelemetry.trace import get_current_span
-        from opentelemetry.sdk.trace import Span
-        from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator
+        from opentelemetry.trace.propagation.tracecontext import (
+            TraceContextTextMapPropagator,
+        )
         tokens = arguments.split(' ', 1)
         response_path = tokens[0]
         traceparent = tokens[1]
@@ -379,7 +419,9 @@
     elif command == 'SPAN_TRACEPARENT':
         from opentelemetry.sdk.trace import Span
         from opentelemetry.trace import set_span_in_context
-        from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator
+        from opentelemetry.trace.propagation.tracecontext import (
+            TraceContextTextMapPropagator,
+        )
         tokens = arguments.split(' ', 1)
         response_path = tokens[0]
         if len(tokens) == 1:
@@ -428,7 +470,9 @@
     elif command == 'LINK_CREATE':
         from opentelemetry.sdk.trace import Span
         from opentelemetry.trace import get_current_span
-        from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator
+        from opentelemetry.trace.propagation.tracecontext import (
+            TraceContextTextMapPropagator,
+        )
         global next_link_id
         tokens = arguments.split(' ', 3)
         response_path = tokens[0]
@@ -557,7 +601,9 @@
     elif command == 'LOG_RECORD':
         from opentelemetry._logs import get_logger
         from opentelemetry.sdk._logs._internal import SeverityNumber
-        from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator
+        from opentelemetry.trace.propagation.tracecontext import (
+            TraceContextTextMapPropagator,
+        )
         tokens = arguments.split(' ', 3)
         traceparent = tokens[0]
         log_time = tokens[1]

(Truncated to last 2500 characters out of 9968)
⚠️ MARKDOWN / markdown-table-formatter - 1 error
1 files contain markdown tables to format:
- README.md
⚠️ BASH / shfmt - 1 error
diff src/usr/share/opentelemetry_shell/api.sh.orig src/usr/share/opentelemetry_shell/api.sh
--- src/usr/share/opentelemetry_shell/api.sh.orig
+++ src/usr/share/opentelemetry_shell/api.sh
@@ -24,8 +24,8 @@
 
 # loadable builtins
 if \[ -n "${BASH_VERSION:-}" ] && \[ "${OTEL_SHELL_CONFIG_LOADABLE_BUILTINS:-TRUE}" = TRUE ]; then
-  \enable -f /usr/lib/bash/rm rm 2> /dev/null || \true
-  \enable -f /usr/lib/bash/mkfifo mkfifo 2> /dev/null || \true
+  \enable -f /usr/lib/bash/rm rm 2>/dev/null || \true
+  \enable -f /usr/lib/bash/mkfifo mkfifo 2>/dev/null || \true
 fi
 
 # basic setup
@@ -176,7 +176,7 @@
 fi
 
 _otel_resolve_package_version() {
-  ( \dpkg -s "$1" || \rpm -qi "$1" || {
+  (\dpkg -s "$1" || \rpm -qi "$1" || {
     _apk_package="$1"
     _apk_version="$(\apk info -e -v "$_apk_package" | \head -n 1)" # SKIP_DEPENDENCY_CHECK
     case "$_apk_version" in
@@ -186,7 +186,7 @@
       *-r[0-9]*) _apk_version="${_apk_version%-r*}" ;;
     esac
     [ -z "$_apk_version" ] || \echo "Version: $_apk_version"
-  } ) 2> /dev/null | \grep Version | \cut -d : -f 2 | \tr -d ' ' || \true
+  }) 2>/dev/null | \grep Version | \cut -d : -f 2 | \tr -d ' ' || \true
 }
 
 otel_span_current() {

See detailed reports in MegaLinter artifacts
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is provided by OX Security
Show us your support by starring ⭐ the repository

Co-authored-by: plengauer <100447901+plengauer@users.noreply.github.com>
Copilot AI changed the title [WIP] Add optional explicit timestamp for metrics in api.sh Support explicit timestamps for metric observations Oct 12, 2026
Copilot AI requested a review from plengauer October 12, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support optional explicit timestamp for metrics (counters) in api.sh, consistent with spans and logs

2 participants