![Search icon](https://hackernoon.imgix.net/search-new.png?w=19&h=19)
Ngaphambili, xa sithetha nge-backend, ngokuqhelekileyo sibhekisela kwisicelo esinye esikhulu kunye nedatha enye, enkulu, kunye nokugawulwa kwemithi kwakwanele ukubeka iliso. Ngoku, ngenxa yetekhnoloji efana Kubernetes , ii-microservices ziye zaba ngumgangatho. Izicelo zininzi kwaye zisasazwe, kwaye ukugawulwa kwemveli akusenelanga ukulungisa ingxaki kunye nokuxilonga iingxaki kwizicelo zethu.
Isisombululo esihle kakhulu sokulungiselela ukubeka iliso yi-OpenTelemetry - isixhobo sanamhlanje esinokusetyenziswa ukulungisa iimpazamo kunye nohlalutyo lokusebenza kwiinkqubo ezisasazwayo.
Eli nqaku lenzelwe iingcali ze-IT ezifuna ukwandisa ulwazi lwabo ekuphuculeni umva. Apha ngezantsi, siza kuchaza ukuba yintoni i-OpenTelemetry, iikhonsepthi zayo eziphambili, kunye neengxaki ezinceda ukuzisombulula. Ukuba unomdla kwindlela i-OpenTelemetry enokuyitshintsha ngayo indlela yakho yokubeka iliso kunye nokulungiswa kweesistim ze-backend, ukuqinisa ukuthembeka kwazo kunye nokusebenza kakuhle - funda.
Iinkampani ezinkulu zetekhnoloji ziqale zajongana nomngeni wokugawulwa kwemithi kunye nokulandela umkhondo ngasekupheleni kweminyaka yoo-2000. Ngo-2010, uGoogle wapapasha iphepha,
Kwi-2014, i-Kubernetes yavela, yenza lula kakhulu ukuphuhliswa kwee-microservices kunye nezinye iinkqubo ezisasazwa ngamafu. Oku kukhokelele ekubeni iinkampani ezininzi zijongane nemiba ngokugawulwa kwemithi kunye nokulandela umkhondo kwiinkonzo ezincinci. Ukumisela umkhondo osasaziweyo, umgangatho we-OpenTracing, owamkelwa yi-CNCF, kunye neprojekthi ye-OpenCensus kaGoogle yenziwa.
Ngo-2019, iiprojekthi ze-OpenTracing kunye ne-OpenCensus zabhengeza ukudityaniswa phantsi kwegama le-OpenTelemetry. Eli qonga lidibanisa ezona zenzo zilungileyo eziqokelelwe kwiminyaka emininzi, evumela ukudityaniswa komthungo wokulandela umkhondo, ukugawulwa kwemithi, kunye neemetrics kuyo nayiphi na inkqubo, nokuba inzima kangakanani na.
Namhlanje, i-OpenTelemetry ayisiyoprojekthi nje; ngumgangatho weshishini lokuqokelela kunye nokuhambisa idatha ye-telemetry. Iphuhliswa kwaye ixhaswa luluntu lweengcali kunye neenkampani ezikhokela imarike ezifana neGoogle kunye neMicrosoft. Iprojekthi iyaqhubeka nokuvela, ifumana amandla amatsha ukwenza lula ukudibanisa kunye nenkqubo yokusebenzisa.
I-OpenTelemetry iyiseti ebanzi yezenzo kunye nezixhobo ezichaza ukuba zeziphi iimpawu zesicelo esinokuthi zivelise ukusebenzisana nehlabathi langaphandle, kunye nendlela le miqondiso enokuthi iqokelelwe kwaye ibonakale ngayo ukujonga imeko yezicelo kunye nenkqubo yonke. Iindidi ezintathu eziphambili zemiqondiso kukulandela , ukugawulwa , kunye nokuqokelela kweemetrics .
**Masijonge ngakumbi icandelo ngalinye: \
I-OpenTelemetry yazisa ingqikelelo yeemeko zokusebenza. Umxholo uquka iimpawu ezinje nge `trace_id`
(isazisi somsebenzi wangoku) kunye `span_id`
(isazisi sesicelo esingaphantsi, kunye nesicelo ngasinye esinesicelo esinesinye `span_id`
eyodwa).
Ukongeza, umxholo unokuqulatha ulwazi olungatshintshiyo, olufana negama lendawo apho usetyenziso lubekwe khona okanye igama lemeko-bume (prod/qa). Ezi nkalo, ezaziwa njengezixhobo kwi-OpenTelemetry terminology, zincanyathiselwe kwilog nganye, imetriki, okanye umkhondo wokukhangela lula. Imixholo inokubandakanya kwakhona idatha eguquguqukayo, njengesichongi sesiphelo sangoku ( `http_path: "GET /user/:id/info"`
), enokuthi iqhotyoshelwe ngokukhethiweyo kumaqela elogi, iimetrikhi, okanye iitrayisi.
Iimeko ze-OpenTelemetry zinokugqithiswa phakathi kwezicelo ezahlukeneyo kusetyenziswa iiprothokholi zokusasaza umxholo. Ezi prothokholi ziquka iiseti zeheader ezongezwe kwisicelo ngasinye seHTTP okanye se-gRPC okanye iiheader zemiyalezo yemigca. Oku kuvumela izicelo ezisezantsi ukuba zakhe kwakhona umxholo wokusebenza kwezi zihloko.
Nantsi eminye imizekelo yokusasazwa komxholo:
B3-Usasazo Olu luhlu lweeheader ( x-b3-*
) eziphuhliselwe ekuqaleni indlela yokukhangela iZipkin. Yatshintshwa ibe yi-OpenTracing kwaye isetyenziswa zizixhobo ezininzi kunye namathala eencwadi. I-B3-Propagation ithwala trace_id
/ span_id
kunye neflegi ebonisa ukuba isampulu iyimfuneko.
I-W3C Trace Context Iphuhliswe liqela elisebenzayo le-W3C, lo mgangatho umanyanisa iindlela ezahlukeneyo zokusasaza umxholo ube kumgangatho omnye kwaye awugqibekanga kwi-OpenTelemetry. Umzekelo omhle wokusebenzisa le migangatho kukulandelela ukuphunyezwa kwesicelo esigqithiswa kwiinkonzo ezincinci eziphunyezwe ngobuchwephesha obahlukeneyo ngaphandle kokubeka esichengeni ukubekwa esweni kunye nokulungiswa kwempazamo.
Ukulandelela yinkqubo yokurekhoda kwaye emva koko ube nombono wexesha lendlela yesicelo ngokusebenzisa iinkonzo ezincinci ezininzi.
Kumboniso, ibha nganye ibizwa ngokuba yi-"span" kwaye ine- "span_id" eyodwa. Ubude bengcambu bubizwa ngokuba yi "trace" kwaye ino "trace_id" , esebenza njengesichongi sesicelo sonke.
Olu hlobo lomboniso lukuvumela ukuba:
trace_id
kunye ne span_id
ukuze isetyenziswe kwezinye iimpawu.
Nangona kubonakala kulula, ukugawulwa kwemithi kusesona sixhobo sinamandla sokuxilonga iingxaki. I-OpenTelemetry iphucula ukugawulwa kwemveli ngokongeza ulwazi lomxholo. Ngokukodwa, ukuba umkhondo osebenzayo ukhona, `trace_id` kunye ne `span_id` iimpawu zongezwa ngokuzenzekelayo kwiilog, ezizinxulumanisa nokulandelela ixesha. Ngaphezu koko, iimpawu zelogi zingabandakanya ulwazi olungatshintshiyo olusuka kumxholo we-OpenTelemetry, njengesichongi sendawo yokusebenzela, kunye nolwazi oluguquguqukayo, njengesichongi se-HTTP sangoku (`http_path: "GET /user/:id"`).
Usebenzisa i `trace_id`, ungafumana logs kuzo zonke iimicroservices ezinxulumene nesicelo sangoku, ngelixa `span_id` ikuvumela ukuba wahlule phakathi kwezicelo ezisezantsi. Umzekelo, kwimeko yokuzama kwakhona, iilogi ezivela kwiinzame ezahlukeneyo ziya kuba ezahlukeneyo `span_id`s. Ukusebenzisa ezi zichongi kwenza uhlalutyo olukhawulezayo lokuziphatha kwenkqubo yonke ngexesha lokwenyani, ukukhawulezisa ukuxilongwa kwengxaki kunye nokwandisa uzinzo nokuthembeka.
Ukuqokelelwa kweemetriki kubonelela ngedatha yobungakanani ekusebenzeni kwesixokelelwano, esifana nokubambezeleka, amazinga eempazamo, ukusetyenziswa kovimba, nokunye. Ukujongwa kwexesha langempela leemethrikhi kukuvumela ukuba uphendule ngokukhawuleza kwiinguqu zokusebenza, uthintele ukungaphumeleli kunye nokudinwa kwezixhobo, kwaye uqinisekise ukufumaneka okuphezulu kunye nokuthembeka kwesicelo kubasebenzisi.
Ukudityaniswa nokugcinwa kweemetriki kunye neenkqubo zokubonwayo ezifana nePrometheus kunye neGrafana yenza kube lula ukujonga le datha, ukwenza lula ukubeka iliso.
Abaqokeleli bemetriki be-OpenTelemetry bayahambelana nemigangatho ye-Prometheus kunye ne-OpenMetrics, eyenza kube lula ukutshintshela kwizisombululo ze-OpenTelemetry ngaphandle kotshintsho olubalulekileyo. I-OpenTelemetry SDK ivumela imizekelo ye-trace_id ukuba ithunyelwe ngaphandle kunye ne-metrics, iyenze kube lula ukunxibelelanisa i-metrics kunye nemizekelo yelogi kunye nokulandela.
Ngokudibeneyo, iilog, iimetrics, kunye nokulanda kudala imbono ebanzi yemeko yenkqubo:
Ukongeza kumacandelo amathathu aphambili, i-OpenTelemetry ibandakanya iikhonsepthi zeSampuli, imithwalo, kunye nolawulo lweemeko zokusebenza.
Kwiinkqubo zomthwalo ophezulu, umthamo welogi kunye neetrayisi ziba mkhulu, zifuna izibonelelo ezininzi zeziseko kunye nokugcinwa kwedatha. Ukujongana nalo mba, imigangatho ye-OpenTelemetry ibandakanya isampulu yesignali - ukukwazi ukuthumela ngaphandle kuphela inxalenye yetrayisi kunye neelog. Umzekelo, ungathumela ngaphandle imiqondiso eneenkcukacha ukusuka kwipesenti yezicelo, izicelo eziqhuba ixesha elide, okanye izicelo zempazamo. Le ndlela ivumela isampulu eyaneleyo yokwakha izibalo ngelixa igcina izixhobo ezibalulekileyo.
Nangona kunjalo, ukuba inkqubo nganye igqiba ngokuzimeleyo ukuba zeziphi izicelo zokubeka iliso ngokweenkcukacha, siphela sinombono oqhekezayo wesicelo ngasinye. Ezinye iisistim zinokuthumela ngaphandle idatha eneenkcukacha ngelixa ezinye zinokuthumela ngaphandle kancinci okanye zingakuthumeli ngaphandle konke.
Ukusombulula le ngxaki, iindlela ze-OpenTelemetry zokusasaza umxholo zithumela iflegi yesampulu kunye ne `trace_id`/`span_id`. Oku kuqinisekisa ukuba ukuba inkonzo yokuqala efumana isicelo somsebenzisi ithatha isigqibo sokuba isicelo kufuneka sibekwe esweni ngokweenkcukacha, zonke ezinye iinkqubo ziya kulandela. Kungenjalo, zonke iisistim kufuneka ngokuyinxenye okanye zingakhupheli ngaphandle imiqondiso ukuze kugcinwe izibonelelo. Le ndlela ibizwa ngokuba yi "Head Sampling" -isigqibo esenziwe ekuqaleni kokwenziwa kwesicelo, ngokungenamkhethe okanye ngokusekwe kwezinye iimpawu zegalelo.
Ngaphandle koko, i-OpenTelemetry ixhasa "iSampuli yomsila," apho zonke izicelo zihlala zithumela zonke iimpawu ngokweenkcukacha, kodwa isithinteli esiphakathi sikhona. Emva kokuqokelela yonke idatha, le buffer ithatha isigqibo sokuba igcine idatha epheleleyo okanye igcine kuphela isampulu engaphelelanga. Le ndlela ivumela isampulu emele ngakumbi yodidi ngalunye lwesicelo (iphumelele/inde/impazamo) kodwa ifuna ukusetwa kweziseko zophuhliso ezongezelelweyo.
Indlela yoMthwalo ivumela izibini zexabiso elingundoqo elingenasizathu ukuba lihanjiswe kunye ne trace_id
/ span_id
, ezidlula ngokuzenzekelayo phakathi kwazo zonke iinkonzo ezincinci ngexesha lokuqhuba isicelo. Oku kuluncedo ekugqithiseni ulwazi olongezelelweyo olufunekayo kuyo yonke indlela yokucela-njengolwazi lomsebenzisi okanye imimiselo yemo engqongileyo yexesha lokusebenza.
Umzekelo wesihloko sokuhambisa imithwalo ngokomgangatho weW3C: tracestate: rojo=00f067aa0ba902b7,congo=t61rcWkgMzE,userId=1c30032v5
Nantsi eminye imizekelo yokusetyenziswa kwempahla:
Ukupasa koMxholo woShishino Ulwazi olufana userId
, productId
, okanye deviceId
inokudluliselwa kuzo zonke iimicroservices. Iiaplikeshini zinokungena ngokuzenzekelayo olu lwazi, zivumela uphendlo lwelogi ngokwemeko yomsebenzisi kwisicelo sokuqala.
Uqwalaselo oluKhethekileyo lweParameters Useto lwee-SDKs okanye iziseko zophuhliso.
Ukuhambisa iiFlegi zeeFlegi ezinceda abalinganisi bomthwalo benze izigqibo zomzila. Ngexesha lovavanyo, ezinye izicelo zinokufuna ukuhanjiswa ukuze zihlekise ngasemva. Ekubeni imithwalo ithunyelwa ngokuzenzekelayo kuzo zonke iinkonzo, akukho mfuneko yokwenza iiprotocol ezongezelelweyo-seta nje umgaqo kwi-balancer yomthwalo.
Qaphela ukuba ngelixa impembelelo yokusebenza yoMthwalo incinci, ukusetyenziswa ngokugqithisileyo kunokunyusa kakhulu inethiwekhi kunye nomthwalo wenkonzo. Khetha ngononophelo ukuba yeyiphi idatha oyifunayo ngokwenene ukuba udlule kwi-Baggage ukunqanda imiba yokusebenza.
Ukusebenzisa i-OpenTelemetry kwinqanaba leziseko ezingundoqo kubandakanya ukudibanisa i-OpenTelemetry backends kuyilo lwesicelo kunye nokuqwalasela isiseko sokuhlanganiswa kwedatha.
Inkqubo inezigaba ezine:
Ukudityaniswa kweSicelo Kwinqanaba lokuqala, ii-SDK ze-OpenTelemetry zidityaniswe ngokuthe ngqo kwizicelo zokuqokelela iimethrikhi, iilogi, kunye nomkhondo, ukuqinisekisa ukuhamba okuqhubekayo kwedatha malunga nokusebenza kwecandelo ngalinye lenkqubo.
Ukuqwalasela abaThumeli bangaphandle Idatha eqokelelweyo ihanjiswa kwizicelo ngokusebenzisa abathumeli kumazwe angaphandle kwiinkqubo zangaphandle zokuqhubela phambili ukuqhubela phambili, njengokuloga, ukubeka iliso, ukulandelela, okanye uhlalutyo lweenkqubo, kuxhomekeke kwiimfuno zakho.
Ukudityaniswa nokuGcina Eli nqanaba lingabandakanya idatha yesiqhelo, ukuyiphucula ngolwazi olongezelelweyo, kunye nokudibanisa idatha esuka kwimithombo eyahlukeneyo ukudala umbono odibeneyo wombuso wenkqubo.
Ukubonwa kwedatha Ekugqibeleni, idatha esetyenzisiweyo inikezelwa njengeedeshibhodi kwiinkqubo ezifana neGrafana (yeemethrikhi kunye neetrayisi) okanye i-Kibana (yeelogi). Oku kuvumela amaqela ukuba ahlole ngokukhawuleza impilo yenkqubo, ukuchonga imiba kunye neendlela, kunye nokuseta izilumkiso ezisekelwe kwiimpawu ezenziweyo.
Ukudibanisa nesicelo, kufuneka uqhagamshele i-OpenTelemetry SDK efanelekileyo yolwimi lwenkqubo olusetyenziswayo okanye uqeshe amathala eencwadi kunye nezikhokelo ezixhasa ngokuthe ngqo i-OpenTelemetry. I-OpenTelemetry ihlala isebenzisa ujongano olusetyenziswa ngokubanzi olusuka kumathala eencwadi aziwayo, ivumela ukutshintshwa kokungena. Umzekelo, ilayibrari yeMicrometer iqhele ukusetyenziselwa ukuqokelela i-metrics kwi-ecosystem yeJava. I-OpenTelemetry SDK inikeza ukuphunyezwa kwayo kwe-Micrometer interfaces, eyenza ukuba i-metric ithumele ngaphandle kokutshintsha ikhowudi yesicelo esiphambili. Ngaphezu koko, i-OpenTelemetry ibonelela ngokuphunyezwa kwe-OpenTracing endala kunye ne-OpenCensus interfaces, iququzelela ukufuduka okugudileyo kwi-OpenTelemetry.
Kwiinkqubo ze-IT, i-OpenTelemetry inokuba ngundoqo kwikamva lezinto ezithembekileyo nezisebenzayo. Esi sixhobo senza lula ukulungisa iimpazamo kunye nokubeka iliso kwaye sivula amathuba okuqonda okunzulu kokusebenza kwesicelo kunye nokuphucula kwinqanaba elitsha. Joyina uluntu lwe-OpenTelemetry ukunceda ukubumba ikamva apho uphuhliso lwasemva lulula kwaye lusebenza ngakumbi!