Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Challenge] Add OpenTelemetry logging #365

Closed
juntao opened this issue Aug 19, 2021 · 27 comments
Closed

[Challenge] Add OpenTelemetry logging #365

juntao opened this issue Aug 19, 2021 · 27 comments
Assignees
Labels
good first issue Good for newcomers LFX Mentorship Tasks for LFX Mentorship participants

Comments

@juntao
Copy link
Member

juntao commented Aug 19, 2021

Please fork this repo and complete the challenge in your own repo. Once you are done, post your repo’s github link, as well as a screenshot demonstrating the logging messages, as a comment under this issue.

OpenTelemetry is a new standard for cloud native application logging, tracing, and monitoring. It has agent SDKs in mainstream programming languages, including C++.

https://opentelemetry.io/docs/

This coding challenge is to embed a C++ agent into WasmEdge. The agent logs messages from WasmEdge to STDOUT. You could use OpenTelemetry agent to replace existing logging calls in the code. You do NOT to replace logging for the entire project. Just do it in a few places, either to replace existing logging or add new logging, to demonstrate that you know how to do it.

Examples:

https://github.com/open-telemetry/opentelemetry-cpp/tree/main/examples/simple

https://github.com/open-telemetry/opentelemetry-cpp/tree/main/examples/metrics_simple

Good luck!

Related to #290

@juntao juntao self-assigned this Aug 19, 2021
@juntao juntao added LFX Mentorship Tasks for LFX Mentorship participants good first issue Good for newcomers labels Aug 19, 2021
@juntao juntao changed the title Coding challenge: Coding challenge: Add OpenTelemetry logging and tracing Coding challenge: Add OpenTelemetry logging and tracing Aug 20, 2021
@spider0061
Copy link
Contributor

@juntao Can you please provide an example of logging and tracing calls in the WasmEdge codebase. I have got the idea that I have to replace logging and tracing statements with the OpenTelemetry agent. But I am unable to locate the statements.
Thanks

@juntao
Copy link
Member Author

juntao commented Aug 20, 2021 via email

@spider0061
Copy link
Contributor

Run a WasmEdge app and you will see logs printed in the console. You can locate in the source code where they are. Thanks. Cheers Michael
On Fri, Aug 20, 2021 at 7:46 AM Ashutosh Sharma @.***> wrote: @juntao https://github.com/juntao Can you please provide an example of logging and tracing calls in the WasmEdge codebase. I have got the idea that I have to replace logging and tracing statements with the OpenTelemetry agent. But I am unable to locate the statements. Thanks — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#365 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAACUNVWLVS36LM67U3RWBLT5ZFDHANCNFSM5CPG5WLA .
-- Michael Yuan, PhD Fast, safe, portable and serverless Rust programs on Node.js, or as a FaaS http://SecondState.io http://cloud.secondstate.io

@juntao I have found that log statements are defined in log.cpp and we are using spdlog tag. I was running this simple command ./wasmedge --reactor examples/fibonacci.wasm fib 10 10. To find where are the log statements when FunctionType doesnot match located. I was able to find that the error tag is: MismatchCategory::FunctionType. But can you please point me to the file where the types are actuallly matched. I have used grep command as well and went through the returned files but it didn't work.
Thanks

@juntao juntao changed the title Coding challenge: Add OpenTelemetry logging and tracing Coding challenge: Add OpenTelemetry logging Aug 21, 2021
@juntao
Copy link
Member Author

juntao commented Aug 21, 2021

@spider0061 This is a coding challenge. You are supposed to figure out how WasmEdge works with logging today. ;)

That said, you do not have to replace existing logging statements. You can use OpenTelemetry to demonstrate how to add new logging capabilities to this project.

@CruxBox
Copy link

CruxBox commented Aug 21, 2021

Hi,
I have added some trace and logging stub to the interpreter code and maybe this would suffice for the challenge.

My repo link: https://github.com/CruxBox/WasmEdge

And the screenshot I took after I ran the example 'add.wasm' program:
Screenshot from 2021-08-22 00-42-27

As part of the challenege I had to build OpenTelemetry, build WasmEdge, link them so I could use the OTel library, and make appropriate changes in the interpreter code.
Note that the Tracer output is not very detailed but that could be changed.
Also, OTel has 3 types of logging: Errors, Debug, Info.
I chose to go with Debug but I have a screenshot of testing Error too if you'd like.
If there is anything you want me to add/modify let me know.

Thanks,

@William-Mou
Copy link
Contributor

Hi,

I have compiled and installed open-telemetry and WasmEdge successfully today. I have done some code to experiment with the feasibility of embedding a C++ agent into WasmEdge.

Although the code is not perfect, Uphold the "Release early, release often" philosophy, the following is my GitHub link. There is a screenshot of the logging messages in the img folder.

https://github.com/William-Mou/WasmEdge/tree/mou/dev

opentelemetry

I learned a lot from these two Cloud Native projects. Thank You!

@sonder-joker
Copy link
Collaborator

sonder-joker commented Aug 23, 2021

Hi,

I think I understad the log system. The main file for log is log.cpp and log.h. They generate use overload to generate error message and then goto spdlog system. If I want hack, the easy way is to hack those files(What I have make). However, there are some sparate file use spdlog directly by string literal. For those may need directly hack spdlog code in original place.

But I have spand one entirely day to try install opentelemetry-cpp. I try use cmake's FetchContent_Declare to pull it as an git submodule, but it just error at benchmark.cmake generate(follow INSTALL.md. I finially install it success by off the cmake option about opentelemetry-cpp test(-DBUILD_TESTING=OFF). However, FetchContent_Declare work not as same as the spdlog I copied (I'm not familiar with cmake before). Finally I have to make install it in docker and target link it to WasmEdge Common(Too inelegant) and compile it. And finally success run it.

Durning this try, I leran a lot knowledge about cmake. And also have a understand about WasmEdge's log system. I don't know if the apply time pass when I finish issue, but it's still a happy journey about learn.
image
repo : https://github.com/sonder-joker/WasmEdge/

@XingZYu
Copy link
Contributor

XingZYu commented Aug 23, 2021

Hi,

I guess the main task in this challenge is how to embed a tool/agent into WasmEdge.
So following the basic idea of log.h and log.cc, I add tracer.h and tracer.cc to embed a OpenTelemetry tracer with WasmEdge CLI. In this approach we can use OpenTelemetry to trace and log messages. To demonstrate, I just put a simple trace in the main function.

https://github.com/XingZYu/WasmEdge

image

Thanks,

@st9540808
Copy link

Hi WasmEdge team,

I embedded an opentelemetry logging into wasmedger.cpp. Specifically inside the code path of reactor mode. Therefore, it will log whenever wasmedge CLI is called with reactor mode. It might not be the most elegant way to do it, but I managed to do the challenge with the minimum change to the code base.

Screenshot from 2021-08-23 21-59-35

github link: https://github.com/st9540808/WasmEdge

@pavani-17
Copy link

pavani-17 commented Aug 24, 2021

Hi,
I have added logging in Wasmedge using Open Telemetry. I have installed Open Telemetry in the docker image and have added Open Telemetry in cmake using this. I have added the logging commands in tools/wasmedge/wasmedger.cpp file. I hope this would be enough for the challenge. Happy to make any additional changes required.

The link to my repo: WasmedgeLogging

Attached is a picture showing the logging when add.wasm is executed:
Screenshot from 2021-08-24 22-42-09

@himanshutiwariji
Copy link

himanshutiwariji commented Aug 25, 2021

Hi,
repo link - https://github.com/himanshutiwariji/WasmEdge.git

Thank you , Have a good day

@SAtacker
Copy link
Collaborator

SAtacker commented Aug 26, 2021

No matter what I do , this is always present when linked against opentelemetry

tools/wasmedge/CMakeFiles/wasmedge.dir/build.make:83: *** target pattern contains no '%'.  Stop.
make[1]: *** [CMakeFiles/Makefile2:2818: tools/wasmedge/CMakeFiles/wasmedge.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 91%] Linking CXX executable wasmedgeInterpreterCoreTests
[ 91%] Built target wasmedgeMemLimitTests
[ 91%] Built target wasmedgeASTTests
[ 91%] Built target wasmedgec
[ 91%] Built target wasmedgeExternrefTests
[ 91%] Built target wasmedgeInterpreterCoreTests
[ 91%] Built target wasmedgeAOTCoreTests
[ 91%] Built target wasmedge_c
make: *** [Makefile:163: all] Error 2
satacker@ubuntu:~/WasmEdge/build$ 

Complete Traceback
https://pastebin.com/sZ967jgd

Edit: The problem is in opentelemetry-cpp cmake pkg-config

tools/wasmedge/wasmedge: opentelemetry-cpp::version-NOTFOUND
tools/wasmedge/wasmedge: opentelemetry-cpp::common-NOTFOUND
tools/wasmedge/wasmedge: opentelemetry-cpp::trace-NOTFOUND
tools/wasmedge/wasmedge: opentelemetry-cpp::logs-NOTFOUND
tools/wasmedge/wasmedge: opentelemetry-cpp::ostream_log_exporter-NOTFOUND
tools/wasmedge/wasmedge: opentelemetry-cpp::ostream_span_exporter-NOTFOUND
tools/wasmedge/wasmedge: opentelemetry-cpp::zpages-NOTFOUND

@spider0061
Copy link
Contributor

No matter what I do , this is always present when linked against opentelemetry

tools/wasmedge/CMakeFiles/wasmedge.dir/build.make:83: *** target pattern contains no '%'.  Stop.
make[1]: *** [CMakeFiles/Makefile2:2818: tools/wasmedge/CMakeFiles/wasmedge.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 91%] Linking CXX executable wasmedgeInterpreterCoreTests
[ 91%] Built target wasmedgeMemLimitTests
[ 91%] Built target wasmedgeASTTests
[ 91%] Built target wasmedgec
[ 91%] Built target wasmedgeExternrefTests
[ 91%] Built target wasmedgeInterpreterCoreTests
[ 91%] Built target wasmedgeAOTCoreTests
[ 91%] Built target wasmedge_c
make: *** [Makefile:163: all] Error 2
satacker@ubuntu:~/WasmEdge/build$ 

Complete Traceback
https://pastebin.com/sZ967jgd

Edit: The problem is in opentelemetry-cpp cmake pkg-config

tools/wasmedge/wasmedge: opentelemetry-cpp::version-NOTFOUND
tools/wasmedge/wasmedge: opentelemetry-cpp::common-NOTFOUND
tools/wasmedge/wasmedge: opentelemetry-cpp::trace-NOTFOUND
tools/wasmedge/wasmedge: opentelemetry-cpp::logs-NOTFOUND
tools/wasmedge/wasmedge: opentelemetry-cpp::ostream_log_exporter-NOTFOUND
tools/wasmedge/wasmedge: opentelemetry-cpp::ostream_span_exporter-NOTFOUND
tools/wasmedge/wasmedge: opentelemetry-cpp::zpages-NOTFOUND

I have been facing the exact error since 5 days and it is not resolved yet. I have tried a lot of solutions but none of them worked.

@SAtacker
Copy link
Collaborator

SAtacker commented Aug 26, 2021

No matter what I do , this is always present when linked against opentelemetry

tools/wasmedge/CMakeFiles/wasmedge.dir/build.make:83: *** target pattern contains no '%'.  Stop.
make[1]: *** [CMakeFiles/Makefile2:2818: tools/wasmedge/CMakeFiles/wasmedge.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 91%] Linking CXX executable wasmedgeInterpreterCoreTests
[ 91%] Built target wasmedgeMemLimitTests
[ 91%] Built target wasmedgeASTTests
[ 91%] Built target wasmedgec
[ 91%] Built target wasmedgeExternrefTests
[ 91%] Built target wasmedgeInterpreterCoreTests
[ 91%] Built target wasmedgeAOTCoreTests
[ 91%] Built target wasmedge_c
make: *** [Makefile:163: all] Error 2
satacker@ubuntu:~/WasmEdge/build$ 

Complete Traceback
https://pastebin.com/sZ967jgd
Edit: The problem is in opentelemetry-cpp cmake pkg-config

tools/wasmedge/wasmedge: opentelemetry-cpp::version-NOTFOUND
tools/wasmedge/wasmedge: opentelemetry-cpp::common-NOTFOUND
tools/wasmedge/wasmedge: opentelemetry-cpp::trace-NOTFOUND
tools/wasmedge/wasmedge: opentelemetry-cpp::logs-NOTFOUND
tools/wasmedge/wasmedge: opentelemetry-cpp::ostream_log_exporter-NOTFOUND
tools/wasmedge/wasmedge: opentelemetry-cpp::ostream_span_exporter-NOTFOUND
tools/wasmedge/wasmedge: opentelemetry-cpp::zpages-NOTFOUND

I have been facing the exact error since 5 days and it is not resolved yet. I have tried a lot of solutions but none of them worked.

Instead of using whatever is given in opentelemetry-cpp docs try the following after installing opentelemetry-cpp

find_package(opentelemetry-cpp CONFIG REQUIRED)

...


target_include_directories(wasmedge 
  PRIVATE 
  ${OPENTELEMETRY_CPP_INCLUDE_DIRS}
  ${OPENTELEMETRY_CPP_LIBRARY_DIRS}
)

target_link_libraries(wasmedge
  PRIVATE
  wasmedgeVM
  ${OPENTELEMETRY_CPP_LIBRARY_DIRS}  
)

@SAtacker
Copy link
Collaborator

SAtacker commented Aug 26, 2021

To be more generic wasmedge can be any CMake target variable
On a side note: Apologies for making this challenge discussion deviate from its main point but I wonder why docker users didn't face this.

@spider0061
Copy link
Contributor

Hello Mentors,

For the past few days I was facing error in linking opentelemetry with wasmedge. I even contacted the opentelemetry team regarding this as none of the other developers was facing the inevitable error 2. I was finally able to resolve it and here is the screenshot of the changes that I made:
Screenshot from 2021-08-26 12-06-19
In the beginning I thought that it was an easy challenge, indeed it was an easy challenge but I was not aware that I will fall into this much trouble while linking opentelemetry. I have learned about wasmedge and how it is used to run wasm progroms. I also got introduced to webassembly and how webassembly can be a revolutionary step in web development.
I have learned about host modules and functions and currently I am working on them only.
I would like to thank mentors and this challenge really taught me a lot of things and finally I was able to complete it.
Repository Link: https://github.com/spider0061/WasmEdge

Thanks and Regards
Ashutosh Sharma

@vaibhavarora102
Copy link

hi here's the coding challenge solution on GitHub link: https://github.com/vaibhavarora102/WasmEdge

it was indeed very refreshing, and warming up the task. Looking forward to mentors' guidance in the LFX mentorship program.

@OliverShang
Copy link

Hi,

I've spent a few days in linking opentelemetry with wasmedge and building opentelemetry from source, a lot of problems occurred during compiling. I even started a issue in opentelemetry-cpp about build errors, and found out the dependency benchmark should be compiled in PIC(Position Independent Code) mode. At least finally it worked. I embedded an opentelemetry logging into wasmedger.cpp, and learned a lot about wasm in this challenge. Hope I did not miss the deadline.

Repo: https://github.com/OliverShang/WasmEdge

Thanks,

@ZiNai
Copy link

ZiNai commented Aug 27, 2021

Hi,
I spent some time learning the basics of c++ and cmake. After that, I tried to build wasmedge based on build.md on my mac, but there were various strange problems, often stuck at 73%. So I had to try it on my Ubuntu 20.04 cloud host. And I spent a lot of time to install opentelemetry-cpp during the build.
The first time I came into contact with c++ projects. Maybe because of my lack of experience ,I feel that package management and construction are very primitive, which directly caused a very unfriendly development experience!

There is a tip
If your github network is not very good, you can try the following command.

SET URL INSTEAD

git config --global url."https://github.com.cnpmjs.org/".insteadOf https://github.com

UNSET

git config --global --remove-section url."https://github.com.cnpmjs.org/"

My Repo

My ScreenShot

Screen Shot 2021-08-27 at 3 33 49 PM

@alabulei1
Copy link
Contributor

Hi,

I try several ways to embed OpenTelemetry like FetchContent_Declare. But it doesn't work well. Finally, I build and make opentelemetry-cpp, and set opentelemetry-cpp_DIR to the directory where contains config.cmake. Then build wasmedge in the docker. It prints log information successfully. By doing this challenge I learned a lot about cmake, especially "find_package". I enjoy solving the problem.
Thank you!

Screen Shot 2021-08-27 at 8 01 09 AM

Repository Link: https://github.com/Flpha0830/WasmEdge

Hi, could you tell me your name or email when you signed up for the LFX mentorship? I tried to search by your GitHub name and your university. However, I couldn't find you through the applications. Thanks.

@SAtacker
Copy link
Collaborator

In case Anyone is eager to help as the challenge seems to be over already here are my logs which tells me that I haven't installed protobuf,nlohmann-json,libcurl,grpc
However, I have installed those as we can see in

root@4b5d92daa3be:~/wasm_work/WasmEdge/build# l
s /usr/local/lib/cmake/
absl    grpc               protobuf
c-ares  opentelemetry-cpp  re2
root@4b5d92daa3be:~/wasm_work/WasmEdge/build#
 ls /usr/lib/cmake/
clang-12  nlohmann_json

@PratyushD35
Copy link

PratyushD35 commented Aug 27, 2021

Hi,
After a lot of struggles, I myself compiled and build and make OpenTelemetry and then WasmEdge. In my screenshot, I have shown both pass and fail cases. I think I have learned a lot during this small coding Challenge.
This is my Repository Link:https://github.com/PratyushD35/WasmEdge
Screenshot (30)

@SAtacker
Copy link
Collaborator

SAtacker commented Aug 27, 2021

In case Anyone is eager to help as the challenge seems to be over already here are my logs which tells me that I haven't installed protobuf,nlohmann-json,libcurl,grpc
However, I have installed those as we can see in

root@4b5d92daa3be:~/wasm_work/WasmEdge/build# l
s /usr/local/lib/cmake/
absl    grpc               protobuf
c-ares  opentelemetry-cpp  re2
root@4b5d92daa3be:~/wasm_work/WasmEdge/build#
 ls /usr/lib/cmake/
clang-12  nlohmann_json

GitHub link - https://github.com/SAtacker/WasmEdge/tree/satacker
I have added open telemetry using examples from the docs inside the main function of wasmedge runtime

@SAtacker
Copy link
Collaborator

Finally, I succeeded in here
https://github.com/SAtacker/WasmEdge/tree/satacker
image

@gautam-dev-maker
Copy link

gautam-dev-maker commented Aug 27, 2021

Hi,
After spending a lot of time I finally did it. There were lots of build issues , especially unmet dependencies. I installed openTelemetry depedencies using "ci" scripts and everything seems to work fine.
here is my git repository :- https://github.com/gautam-dev-maker/WasmEdge
Proof :-
Screenshot 2021-08-28 at 12 10 46 AM

@chaytanyasinha
Copy link

chaytanyasinha commented Aug 27, 2021

Hello Mentors,
I am sorry for submitting at last moment but I have tried my best to do the challenge efficiently.
I have done the required changes as I installed Open Telemetry and done a few changes in wasmedger.cpp and CMakeList.cpp.
Link to my repository : https://github.com/chaytanyasinha/WasmEdge
I hope you like it!

@juntao juntao changed the title Coding challenge: Add OpenTelemetry logging [Challenge] Add OpenTelemetry logging Sep 27, 2021
@juntao juntao added Hacktoberfest Tasks for Hacktoberfest participants and removed Hacktoberfest Tasks for Hacktoberfest participants labels Sep 27, 2021
@hydai
Copy link
Member

hydai commented Jun 11, 2023

I am closing this issue due to outdated.

@hydai hydai closed this as completed Jun 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers LFX Mentorship Tasks for LFX Mentorship participants
Projects
None yet
Development

No branches or pull requests