newrelic-experimental / gitlab

Gitlab exporters to send metrics,logs,traces to New Relic
11 stars 8 forks source link

gitlab-exporter error: ValueError: timestamp does not conform to RFC 3339 #34

Closed spirrello closed 5 months ago

spirrello commented 9 months ago

Hello,

I've tried versions 1.0.13, 1.0.14 and will probably continue down the list but I keep getting this error. Can you suggest a fix?

2024-01-17 14:00:26,358 INFO [job_logger] [main.py:171] [trace_id=31c92ad56c2602c1a2c7d00f6974e7d8 span_id=2dcd9f722e306bd3 resource.service.name= trace_sampled=True] - 
All data sent to New Relic for pipeline: 74207
Terminating...
Traceback (most recent call last):
  File "/app/main.py", line 197, in <module>
    send_to_nr()
  File "/app/main.py", line 193, in send_to_nr
    p_parent.end(end_time=do_time(str(pipeline_json['finished_at'])))
  File "/app/custom_parsers/__init__.py", line 15, in do_time
    return (int(round(time.mktime(parse(string).timetuple())) * 1000000000))
  File "/usr/local/lib/python3.10/site-packages/pyrfc3339/parser.py", line 87, in parse
    raise ValueError("timestamp does not conform to RFC 3339")
ValueError: timestamp does not conform to RFC 3339

Here is how I'm running the container in my pipelines:

docker run --rm --name gle \
      --env CI_PARENT_PIPELINE=${CI_PIPELINE_ID} \
      --env CI_PROJECT_ID=${CI_PROJECT_ID} \
      --env GLAB_CONVERT_TO_TIMESTAMP=true \
      --env GLAB_ENDPOINT="https://my-internal-gitlab-server.example.com/" \
      --env GLAB_TOKEN=${GITLAB_PIPELINE_TOKEN} \
      --env NEW_RELIC_API_KEY=${NEW_RELIC_API_KEY} \
      dpacheconr/gitlab-exporter:1.0.13
spirrello commented 9 months ago

Interesting enough is that if I rerun the job it succeeds.

2024-01-17 16:45:24,297 INFO [job_logger] [main.py:171] [trace_id=257532a2e173c31f498e25ce2afc7d5c span_id=d95619dafa638749 resource.service.name= trace_sampled=True] - 
2024-01-17 16:45:24,298 INFO [job_logger] [main.py:171] [trace_id=257532a2e173c31f498e25ce2afc7d5c span_id=d95619dafa638749 resource.service.name= trace_sampled=True] - 
2024-01-17 16:45:24,299 INFO [job_logger] [main.py:171] [trace_id=257532a2e173c31f498e25ce2afc7d5c span_id=d95619dafa638749 resource.service.name= trace_sampled=True] - 
All data sent to New Relic for pipeline: 74235
Terminating...
dpacheconr commented 9 months ago

The error usually means the parent trace timestamp is incorrect format, can happen when pipeline hasn't finished. gitlab exporter -> needs to be run as part of your pipeline as triggered job more information here https://newrelic.com/blog/how-to-relic/monitor-gitlab-with-opentelemetry The reason it works when you re-run is because the json returned from gitlab api already contains the end timestamp(finished_at), so it's parsed correctly.

gitlab metrics exporter -> can be run on schedule outside your normal pipelines, as pipeline schedule or as standalone container

dpacheconr commented 5 months ago

no activity for over 5 months, if you still having issues, please re-open