In [1]:
import requests
import datetime
import random
import json
from pprint import pprint
In [2]:
import random                                     
                                                  
                                                  
def generate_span_id():                           
    return format(random.getrandbits(64), "016x") 

def generate_trace_id():                          
    return format(random.getrandbits(128), "032x")
In [3]:
a = {"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"Angular Sample App"}},{"key":"telemetry.sdk.language","value":{"stringValue":"webjs"}},{"key":"telemetry.sdk.name","value":{"stringValue":"opentelemetry"}},{"key":"telemetry.sdk.version","value":{"stringValue":"1.5.0"}}],"droppedAttributesCount":0},"scopeSpans":[{"scope":{"name":"@jufab/opentelemetry-angular-interceptor","version":"1.1.0-2"},"spans":[{"traceId":"6c697d06c5eecac7fd62fbe4d02521e2","spanId":"1c2be1cbaf16deec","name":"HTTP GET","kind":3,"startTimeUnixNano":1660539648581100000,"endTimeUnixNano":1660539648595000000,"attributes":[{"key":"http.method","value":{"stringValue":"GET"}},{"key":"http.url","value":{"stringValue":"http://django-max:8081/"}},{"key":"http.host","value":{"stringValue":"django-max:8081"}},{"key":"http.scheme","value":{"stringValue":"http"}},{"key":"http.target","value":{"stringValue":"/"}},{"key":"http.user_agent","value":{"stringValue":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"}},{"key":"http.status_code","value":{"intValue":200}}],"droppedAttributesCount":0,"events":[],"droppedEventsCount":0,"status":{"code":0},"links":[],"droppedLinksCount":0}]}]}]}
In [4]:
print(json.dumps(a, indent=4))
{
    "resourceSpans": [
        {
            "resource": {
                "attributes": [
                    {
                        "key": "service.name",
                        "value": {
                            "stringValue": "Angular Sample App"
                        }
                    },
                    {
                        "key": "telemetry.sdk.language",
                        "value": {
                            "stringValue": "webjs"
                        }
                    },
                    {
                        "key": "telemetry.sdk.name",
                        "value": {
                            "stringValue": "opentelemetry"
                        }
                    },
                    {
                        "key": "telemetry.sdk.version",
                        "value": {
                            "stringValue": "1.5.0"
                        }
                    }
                ],
                "droppedAttributesCount": 0
            },
            "scopeSpans": [
                {
                    "scope": {
                        "name": "@jufab/opentelemetry-angular-interceptor",
                        "version": "1.1.0-2"
                    },
                    "spans": [
                        {
                            "traceId": "6c697d06c5eecac7fd62fbe4d02521e2",
                            "spanId": "1c2be1cbaf16deec",
                            "name": "HTTP GET",
                            "kind": 3,
                            "startTimeUnixNano": 1660539648581100000,
                            "endTimeUnixNano": 1660539648595000000,
                            "attributes": [
                                {
                                    "key": "http.method",
                                    "value": {
                                        "stringValue": "GET"
                                    }
                                },
                                {
                                    "key": "http.url",
                                    "value": {
                                        "stringValue": "http://django-max:8081/"
                                    }
                                },
                                {
                                    "key": "http.host",
                                    "value": {
                                        "stringValue": "django-max:8081"
                                    }
                                },
                                {
                                    "key": "http.scheme",
                                    "value": {
                                        "stringValue": "http"
                                    }
                                },
                                {
                                    "key": "http.target",
                                    "value": {
                                        "stringValue": "/"
                                    }
                                },
                                {
                                    "key": "http.user_agent",
                                    "value": {
                                        "stringValue": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
                                    }
                                },
                                {
                                    "key": "http.status_code",
                                    "value": {
                                        "intValue": 200
                                    }
                                }
                            ],
                            "droppedAttributesCount": 0,
                            "events": [],
                            "droppedEventsCount": 0,
                            "status": {
                                "code": 0
                            },
                            "links": [],
                            "droppedLinksCount": 0
                        }
                    ]
                }
            ]
        }
    ]
}
In [5]:
timestamp = datetime.datetime.now().timestamp()*1000000000
In [6]:
datetime.datetime.fromtimestamp(1660539648581100000/10**9)
Out[6]:
datetime.datetime(2022, 8, 15, 5, 0, 48, 581100)
In [7]:
dstart = int(datetime.datetime.now().timestamp()*10**9)
dend = int(dstart + 2*60*10**9)
In [8]:
print(dstart, dend)
1663575857025665024 1663575977025665024
In [9]:
traceId = generate_trace_id()
spanId = generate_span_id()
In [10]:
a = """
Otel::Trace(RTEA - Squad Observability & Automação)
    Agenda dur=15s
    Intro Observability dur=1m30s
    Panorama Itaú dur=30s
    Pilares Observability
        Metricas dur=6m
        Logs dur=6m
        Tracing dur=6m
    End-to-End APM x Otel dur=5m
    Squad SRE Team
        YACE dur=4m
        Framework Obs dur=5m
        Dinamica de Trabalho dur=5m
        Single Pane of Glass dur=3m
    Recap dur=1m
    Q & A dur=5m
"""
In [30]:
db = {}
arr = []
row = []
lvl = -1
_ = 4
getlvl = lambda x,y=0: y if x[0] != ' ' else getlvl(x[1:], y+1)
for line in a.split("\n"):
    if line.strip() == "": continue
    print("\n>>>>>>", line, "\n\n")
    dbprint(db)
    clvl = getlvl(line)
    dur = '0'
    line2 = line.split(" ")
    if line2[-1].startswith("dur="):
        line = " ".join(line2[:-1])
        dur = line2[-1].replace("dur=", "")
    line = line.strip()
    print("lvl", lvl, "clvl", clvl)
    print([i['name'] for i in arr])
    if clvl > lvl:
        if clvl == 0:
            db["name"] = line
            db["dur"] = dur
            db["spanid"] = generate_span_id()
            db["children"] = []
            arr.append(db)
        else:
            doc = {
                "name": line,
                "dur": dur,
                "spanid": generate_span_id(),
                "children": [],
            }
#             if clvl//_ == 2:
#                 row.append([arr[-1]['name'], line])
#             if clvl//_ == 4:
#                 for user in 'ABCDE':
#                     print(">>>> add", doc)
#                     doc['children'].append({
#                         "name": "user"+user,
#                         "children": [],
#                     })
            arr[-1]['children'].append(doc)
            arr.append(doc)
    elif clvl == lvl:
        print("clvl", clvl, clvl//_)
        #print(arr[(clvl//_)-1]['name'])
        doc = {
            "name": line,
            "dur": dur,
            "spanid": generate_span_id(),
            "children": [],
        }
        arr = arr[:-1]
        arr[(clvl//_)-1]['children'].append(doc)
        arr.append(doc)
#         if clvl//_ == 2:
#             row.append({
#                 "epic": [arr[-1]['name'], line])
#         if clvl//_ == 4:
#             for user in 'ABCDE':
#                 doc['children'].append({
#                     "name": "user"+user,
#                     "children": [],
#                 })
    elif clvl < lvl:
        arr = arr[:clvl//_]
        doc = {
            "name": line,
            "dur": dur,
            "spanid": generate_span_id(),
            "children": [],
        }
        arr[-1]['children'].append(doc)
        arr.append(doc)
    print("end", [i['name'] for i in arr])
    dbprint(db)
    lvl = clvl
>>>>>> Otel::Trace(RTEA - Squad Observability & Automação) 


lvl -1 clvl 0
[]
end ['Otel::Trace(RTEA - Squad Observability & Automação)']
 Otel::Trace(RTEA - Squad Observability & Automação) 0

>>>>>>     Agenda dur=15s 


 Otel::Trace(RTEA - Squad Observability & Automação) 0
lvl 0 clvl 4
['Otel::Trace(RTEA - Squad Observability & Automação)']
end ['Otel::Trace(RTEA - Squad Observability & Automação)', 'Agenda']
 Otel::Trace(RTEA - Squad Observability & Automação) 0
	 Agenda 15s

>>>>>>     Intro Observability dur=1m30s 


 Otel::Trace(RTEA - Squad Observability & Automação) 15s
	 Agenda 15s
lvl 4 clvl 4
['Otel::Trace(RTEA - Squad Observability & Automação)', 'Agenda']
clvl 4 1
end ['Otel::Trace(RTEA - Squad Observability & Automação)', 'Intro Observability']
 Otel::Trace(RTEA - Squad Observability & Automação) 15s
	 Agenda 15s
	 Intro Observability 1m30s

>>>>>>     Panorama Itaú dur=30s 


 Otel::Trace(RTEA - Squad Observability & Automação) 1m45s
	 Agenda 15s
	 Intro Observability 1m30s
lvl 4 clvl 4
['Otel::Trace(RTEA - Squad Observability & Automação)', 'Intro Observability']
clvl 4 1
end ['Otel::Trace(RTEA - Squad Observability & Automação)', 'Panorama Itaú']
 Otel::Trace(RTEA - Squad Observability & Automação) 1m45s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s

>>>>>>     Pilares Observability 


 Otel::Trace(RTEA - Squad Observability & Automação) 2m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
lvl 4 clvl 4
['Otel::Trace(RTEA - Squad Observability & Automação)', 'Panorama Itaú']
clvl 4 1
end ['Otel::Trace(RTEA - Squad Observability & Automação)', 'Pilares Observability']
 Otel::Trace(RTEA - Squad Observability & Automação) 2m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 0

>>>>>>         Metricas dur=6m 


 Otel::Trace(RTEA - Squad Observability & Automação) 2m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 0
lvl 4 clvl 8
['Otel::Trace(RTEA - Squad Observability & Automação)', 'Pilares Observability']
end ['Otel::Trace(RTEA - Squad Observability & Automação)', 'Pilares Observability', 'Metricas']
 Otel::Trace(RTEA - Squad Observability & Automação) 2m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 0
		 Metricas 6m

>>>>>>         Logs dur=6m 


 Otel::Trace(RTEA - Squad Observability & Automação) 8m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 6m
		 Metricas 6m
lvl 8 clvl 8
['Otel::Trace(RTEA - Squad Observability & Automação)', 'Pilares Observability', 'Metricas']
clvl 8 2
end ['Otel::Trace(RTEA - Squad Observability & Automação)', 'Pilares Observability', 'Logs']
 Otel::Trace(RTEA - Squad Observability & Automação) 8m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 6m
		 Metricas 6m
		 Logs 6m

>>>>>>         Tracing dur=6m 


 Otel::Trace(RTEA - Squad Observability & Automação) 14m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 12m
		 Metricas 6m
		 Logs 6m
lvl 8 clvl 8
['Otel::Trace(RTEA - Squad Observability & Automação)', 'Pilares Observability', 'Logs']
clvl 8 2
end ['Otel::Trace(RTEA - Squad Observability & Automação)', 'Pilares Observability', 'Tracing']
 Otel::Trace(RTEA - Squad Observability & Automação) 14m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 12m
		 Metricas 6m
		 Logs 6m
		 Tracing 6m

>>>>>>     End-to-End APM x Otel dur=5m 


 Otel::Trace(RTEA - Squad Observability & Automação) 20m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 18m
		 Metricas 6m
		 Logs 6m
		 Tracing 6m
lvl 8 clvl 4
['Otel::Trace(RTEA - Squad Observability & Automação)', 'Pilares Observability', 'Tracing']
end ['Otel::Trace(RTEA - Squad Observability & Automação)', 'End-to-End APM x Otel']
 Otel::Trace(RTEA - Squad Observability & Automação) 20m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 18m
		 Metricas 6m
		 Logs 6m
		 Tracing 6m
	 End-to-End APM x Otel 5m

>>>>>>     Squad SRE Team 


 Otel::Trace(RTEA - Squad Observability & Automação) 25m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 18m
		 Metricas 6m
		 Logs 6m
		 Tracing 6m
	 End-to-End APM x Otel 5m
lvl 4 clvl 4
['Otel::Trace(RTEA - Squad Observability & Automação)', 'End-to-End APM x Otel']
clvl 4 1
end ['Otel::Trace(RTEA - Squad Observability & Automação)', 'Squad SRE Team']
 Otel::Trace(RTEA - Squad Observability & Automação) 25m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 18m
		 Metricas 6m
		 Logs 6m
		 Tracing 6m
	 End-to-End APM x Otel 5m
	 Squad SRE Team 0

>>>>>>         YACE dur=4m 


 Otel::Trace(RTEA - Squad Observability & Automação) 25m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 18m
		 Metricas 6m
		 Logs 6m
		 Tracing 6m
	 End-to-End APM x Otel 5m
	 Squad SRE Team 0
lvl 4 clvl 8
['Otel::Trace(RTEA - Squad Observability & Automação)', 'Squad SRE Team']
end ['Otel::Trace(RTEA - Squad Observability & Automação)', 'Squad SRE Team', 'YACE']
 Otel::Trace(RTEA - Squad Observability & Automação) 25m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 18m
		 Metricas 6m
		 Logs 6m
		 Tracing 6m
	 End-to-End APM x Otel 5m
	 Squad SRE Team 0
		 YACE 4m

>>>>>>         Framework Obs dur=5m 


 Otel::Trace(RTEA - Squad Observability & Automação) 29m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 18m
		 Metricas 6m
		 Logs 6m
		 Tracing 6m
	 End-to-End APM x Otel 5m
	 Squad SRE Team 4m
		 YACE 4m
lvl 8 clvl 8
['Otel::Trace(RTEA - Squad Observability & Automação)', 'Squad SRE Team', 'YACE']
clvl 8 2
end ['Otel::Trace(RTEA - Squad Observability & Automação)', 'Squad SRE Team', 'Framework Obs']
 Otel::Trace(RTEA - Squad Observability & Automação) 29m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 18m
		 Metricas 6m
		 Logs 6m
		 Tracing 6m
	 End-to-End APM x Otel 5m
	 Squad SRE Team 4m
		 YACE 4m
		 Framework Obs 5m

>>>>>>         Dinamica de Trabalho dur=5m 


 Otel::Trace(RTEA - Squad Observability & Automação) 34m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 18m
		 Metricas 6m
		 Logs 6m
		 Tracing 6m
	 End-to-End APM x Otel 5m
	 Squad SRE Team 9m
		 YACE 4m
		 Framework Obs 5m
lvl 8 clvl 8
['Otel::Trace(RTEA - Squad Observability & Automação)', 'Squad SRE Team', 'Framework Obs']
clvl 8 2
end ['Otel::Trace(RTEA - Squad Observability & Automação)', 'Squad SRE Team', 'Dinamica de Trabalho']
 Otel::Trace(RTEA - Squad Observability & Automação) 34m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 18m
		 Metricas 6m
		 Logs 6m
		 Tracing 6m
	 End-to-End APM x Otel 5m
	 Squad SRE Team 9m
		 YACE 4m
		 Framework Obs 5m
		 Dinamica de Trabalho 5m

>>>>>>         Single Pane of Glass dur=3m 


 Otel::Trace(RTEA - Squad Observability & Automação) 39m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 18m
		 Metricas 6m
		 Logs 6m
		 Tracing 6m
	 End-to-End APM x Otel 5m
	 Squad SRE Team 14m
		 YACE 4m
		 Framework Obs 5m
		 Dinamica de Trabalho 5m
lvl 8 clvl 8
['Otel::Trace(RTEA - Squad Observability & Automação)', 'Squad SRE Team', 'Dinamica de Trabalho']
clvl 8 2
end ['Otel::Trace(RTEA - Squad Observability & Automação)', 'Squad SRE Team', 'Single Pane of Glass']
 Otel::Trace(RTEA - Squad Observability & Automação) 39m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 18m
		 Metricas 6m
		 Logs 6m
		 Tracing 6m
	 End-to-End APM x Otel 5m
	 Squad SRE Team 14m
		 YACE 4m
		 Framework Obs 5m
		 Dinamica de Trabalho 5m
		 Single Pane of Glass 3m

>>>>>>     Recap dur=1m 


 Otel::Trace(RTEA - Squad Observability & Automação) 42m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 18m
		 Metricas 6m
		 Logs 6m
		 Tracing 6m
	 End-to-End APM x Otel 5m
	 Squad SRE Team 17m
		 YACE 4m
		 Framework Obs 5m
		 Dinamica de Trabalho 5m
		 Single Pane of Glass 3m
lvl 8 clvl 4
['Otel::Trace(RTEA - Squad Observability & Automação)', 'Squad SRE Team', 'Single Pane of Glass']
end ['Otel::Trace(RTEA - Squad Observability & Automação)', 'Recap']
 Otel::Trace(RTEA - Squad Observability & Automação) 42m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 18m
		 Metricas 6m
		 Logs 6m
		 Tracing 6m
	 End-to-End APM x Otel 5m
	 Squad SRE Team 17m
		 YACE 4m
		 Framework Obs 5m
		 Dinamica de Trabalho 5m
		 Single Pane of Glass 3m
	 Recap 1m

>>>>>>     Q & A dur=5m 


 Otel::Trace(RTEA - Squad Observability & Automação) 43m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 18m
		 Metricas 6m
		 Logs 6m
		 Tracing 6m
	 End-to-End APM x Otel 5m
	 Squad SRE Team 17m
		 YACE 4m
		 Framework Obs 5m
		 Dinamica de Trabalho 5m
		 Single Pane of Glass 3m
	 Recap 1m
lvl 4 clvl 4
['Otel::Trace(RTEA - Squad Observability & Automação)', 'Recap']
clvl 4 1
end ['Otel::Trace(RTEA - Squad Observability & Automação)', 'Q & A']
 Otel::Trace(RTEA - Squad Observability & Automação) 43m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 18m
		 Metricas 6m
		 Logs 6m
		 Tracing 6m
	 End-to-End APM x Otel 5m
	 Squad SRE Team 17m
		 YACE 4m
		 Framework Obs 5m
		 Dinamica de Trabalho 5m
		 Single Pane of Glass 3m
	 Recap 1m
	 Q & A 5m
In [19]:
def dbprint(node, lvl=0):
    if not 'name' in node: return
    print("\t"*lvl, node['name'], node['dur'])
    tdur = []
    for c in node['children']:
        dbprint(c, lvl+1)
        tdur.append(c['dur'])
        
    if len(tdur) > 0:
        tdur = secs2th(sum([th2secs(i) for i in tdur]))
        if node['dur'] != tdur:
            node['dur'] = tdur
dbprint(db)
 Otel::Trace(RTEA - Squad Observability & Automação) 48m15s
	 Agenda 15s
	 Intro Observability 1m30s
	 Panorama Itaú 30s
	 Pilares Observability 18m
		 Metricas 6m
		 Logs 6m
		 Tracing 6m
	 End-to-End APM x Otel 5m
	 Squad SRE Team 17m
		 YACE 4m
		 Framework Obs 5m
		 Dinamica de Trabalho 5m
		 Single Pane of Glass 3m
	 Recap 1m
	 Q & A 5m
In [20]:
def th2secs(ss):
    secs = 0
    if "h" in ss:
        left, right = ss.split("h")
        ss = right
        secs += int(left.strip())*3600
    if "m" in ss:
        left, right = ss.split("m")
        ss = right
        secs += int(left.strip())*60
    if "s" in ss:
        left, right = ss.split("s")
        ss = right
        secs += int(left.strip())*1
    return secs
In [21]:
def secs2th(secs):
    h = []
    if secs >= 3600:
        h.append(str(secs//3600))
        h.append("h")
        secs = secs%3600
    if secs >= 60:
        h.append(str(secs//60))
        h.append("m")
        secs = secs%60
    if secs > 0:
        h.append(str(secs))
        h.append("s")
    return "".join(h)
In [31]:
traceId = generate_trace_id()
print(traceId)
dtstart = (datetime.datetime.now().timestamp()*10**9)
cumd = 0
lvl1span = 1
lvlindex = {}

def sendspans(node, lvl=0, parentSpanID=None, prefix=[]):
    global cumd
    global lvl1span
    spanId = node['spanid']
    name = node['name']
    print(name)
        
    dstart = dtstart + cumd
    dend = dstart + th2secs(node['dur'])*10**9
    parentId = {}
    stringValue = " "*lvl1span
    nameValue = name
    left_prefix = ".".join([str(i) for i in prefix])
    nameValue = f"{left_prefix}. {name}"
    if lvl == 1:
        lvl1span += 1
        stringValue = name
    if lvl > 0:
        parentId = {
            "parentSpanId": parentSpanID,
        }
    payload = {
        "resourceSpans": [
            {
                "resource": {
                    "attributes": [
                        {
                            "key": "service.name",
                            "value": {
                                #"stringValue": "custom-test" + str(random.randint(0,1000))
                                "stringValue": " "*lvl1span,
                            }
                        },
                    ],
                    "droppedAttributesCount": 0
                },
                "scopeSpans": [
                    {
                        "spans": [
                            {
                                **parentId,
                                "traceId": traceId,
                                "spanId": spanId,
                                "name": nameValue,
                                "kind": 3,
                                #"startTimeUnixNano": 1660539648581100000,
                                #"endTimeUnixNano": 1660539648595000000,
                                "startTimeUnixNano": int(dstart),
                                "endTimeUnixNano": int(dend),
                                "attributes": [
                                    {
                                        "key": "http.status_code",
                                        "value": {
                                            "intValue": 200
                                        }
                                    }
                                ],
                                "droppedAttributesCount": 0,
                                "events": [],
                                "droppedEventsCount": 0,
                                "status": {
                                    "code": 0
                                },
                                "links": [],
                                "droppedLinksCount": 0
                            }
                        ]
                    }
                ]
            }
        ]
    }
    rs = requests.post("http://lab003:4318/v1/traces", json=payload)
    rs = requests.post("http://django-max:4318/v1/traces", json=payload)
    print(rs)
    print(rs.text)
    for idx,c in enumerate(node['children']):
        sendspans(c, lvl+1, spanId, [*prefix, idx+1])
        cumd += th2secs(c['dur'])*10**9
    if lvl == 1 and len(node['children']) > 0:
        cumd -= th2secs(node['dur'])*10**9
sendspans(db, prefix=[])
5f2cde5cfd8e40bfac6b51062a03154c
Otel::Trace(RTEA - Squad Observability & Automação)
<Response [200]>
{}
Agenda
<Response [200]>
{}
Intro Observability
<Response [200]>
{}
Panorama Itaú
<Response [200]>
{}
Pilares Observability
<Response [200]>
{}
Metricas
<Response [200]>
{}
Logs
<Response [200]>
{}
Tracing
<Response [200]>
{}
End-to-End APM x Otel
<Response [200]>
{}
Squad SRE Team
<Response [200]>
{}
YACE
<Response [200]>
{}
Framework Obs
<Response [200]>
{}
Dinamica de Trabalho
<Response [200]>
{}
Single Pane of Glass
<Response [200]>
{}
Recap
<Response [200]>
{}
Q & A
<Response [200]>
{}
In [16]:
traceId
Out[16]:
'cb304e5da5428ca5427f096cffdd1a1d'
In [26]:
print(json.dumps(payload, indent=4))
{
    "resourceSpans": [
        {
            "resource": {
                "attributes": [
                    {
                        "key": "service.name",
                        "value": {
                            "stringValue": "custom-test"
                        }
                    }
                ],
                "droppedAttributesCount": 0
            },
            "scopeSpans": [
                {
                    "spans": [
                        {
                            "traceId": "cb304e5da5428ca5427f096cffdd1a1d",
                            "spanId": "32fcddc2df32c0d9",
                            "name": "HTTP GET",
                            "kind": 3,
                            "startTimeUnixNano": 1663575857025665024,
                            "endTimeUnixNano": 1663575977025665024,
                            "attributes": [
                                {
                                    "key": "http.status_code",
                                    "value": {
                                        "intValue": 200
                                    }
                                }
                            ],
                            "droppedAttributesCount": 0,
                            "events": [],
                            "droppedEventsCount": 0,
                            "status": {
                                "code": 0
                            },
                            "links": [],
                            "droppedLinksCount": 0
                        }
                    ]
                }
            ]
        }
    ]
}
In [17]:
payload = {
    "resourceSpans": [
        {
            "resource": {
                "attributes": [
                    {
                        "key": "service.name",
                        "value": {
                            "stringValue": "custom-test"
                        }
                    },
                ],
                "droppedAttributesCount": 0
            },
            "scopeSpans": [
                {
#                     "scope": {
#                         "name": "@jufab/opentelemetry-angular-interceptor",
#                         "version": "1.1.0-2"
#                     },
                    "spans": [
                        {
                            "traceId": traceId,
                            "spanId": spanId,
                            "name": "HTTP GET",
                            "kind": 3,
                            #"startTimeUnixNano": 1660539648581100000,
                            #"endTimeUnixNano": 1660539648595000000,
                            "startTimeUnixNano": dstart,
                            "endTimeUnixNano": dend,
                            "attributes": [
                                {
                                    "key": "http.status_code",
                                    "value": {
                                        "intValue": 200
                                    }
                                }
                            ],
                            "droppedAttributesCount": 0,
                            "events": [],
                            "droppedEventsCount": 0,
                            "status": {
                                "code": 0
                            },
                            "links": [],
                            "droppedLinksCount": 0
                        }
                    ]
                }
            ]
        }
    ]
}
In [55]:
rs = requests.post("http://django-max:4318/v1/traces", json=payload)
In [56]:
rs
Out[56]:
<Response [200]>
In [57]:
rs.json()
Out[57]:
{}
In [58]:
rs.text
Out[58]:
'{}'
In [ ]: