From 0b8ebca7eabb84af085456e27c549628219ecc8f Mon Sep 17 00:00:00 2001 From: Gabriel Darbord Date: Mon, 25 Mar 2024 11:12:34 +0100 Subject: [PATCH] Add temporal options to Zipkin API --- .../OTelZipkinExtractor.class.st | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Famix-OpenTelemetry-Importer/OTelZipkinExtractor.class.st b/src/Famix-OpenTelemetry-Importer/OTelZipkinExtractor.class.st index f17a5f6..b042592 100644 --- a/src/Famix-OpenTelemetry-Importer/OTelZipkinExtractor.class.st +++ b/src/Famix-OpenTelemetry-Importer/OTelZipkinExtractor.class.st @@ -12,6 +12,13 @@ Class { #category : #'Famix-OpenTelemetry-Importer' } +{ #category : #parameters } +OTelZipkinExtractor >> endTs: anInteger [ + "Only return traces where all timestamp are at or before this time in epoch milliseconds." + + self parameters at: 'endTs' put: anInteger +] + { #category : #accessing } OTelZipkinExtractor >> endpoint [ @@ -29,10 +36,7 @@ OTelZipkinExtractor >> extract [ "Ask Zipkin server for traces and parse result." | url data | - url := String streamContents: [ :stream | - stream << endpoint << '/api/v2/traces?'. - self parameters associationsDo: [ :param | - stream << $& << param key << $= << param value asString ] ]. + url := self request. data := ZnClient new get: url. self output: data. ^ (NeoJSONReader on: data readStream) parseList @@ -44,12 +48,28 @@ OTelZipkinExtractor >> limit: anInteger [ self parameters at: 'limit' put: anInteger ] +{ #category : #parameters } +OTelZipkinExtractor >> lookback: anInteger [ + "Only return traces where all timestamp are at or after `endTs - lookback`, in milliseconds." + + self parameters at: 'lookback' put: anInteger +] + { #category : #accessing } OTelZipkinExtractor >> parameters [ ^ parameters ifNil: [ parameters := Dictionary new ] ] +{ #category : #extraction } +OTelZipkinExtractor >> request [ + + ^ String streamContents: [ :stream | + stream << endpoint << '/api/v2/traces?'. + self parameters associationsDo: [ :param | + stream << $& << param key << $= << param value asString ] ] +] + { #category : #parameters } OTelZipkinExtractor >> serviceName: aString [